1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Docker でコンテナ間の通信をする

Last updated at Posted at 2019-07-08

0. はじめに

Dockerの初歩的なところ。

1. Dockerでコンテナ間の通信をしたい

別の言い方をすると、別のコンテナに接続したい。
例) GitLabのコンテナを立てたので、devコンテナから git pull したい

2. 解決策

ネットワークを作って、通信させたいコンテナを同一ネットワークに接続すればよい。

(1) ネットワークの作成

docker network create <network名>

(2) ネットワークにコンテナを追加

docker network connect <network名> <container1>
docker network connect <network名> <container2>

(3) 各コンテナのipアドレスの確認

docker network inspection <network名>

以上です。

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?