30
28

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-compose で立ち上げたコンテナの IP アドレスを調べる

Posted at

やり方

docker run コマンドとかでネットワークを指定せずに立ち上げたコンテナの IP アドレスは、

docker inspect -f "{{.NetworkSettings.IPAddress}}" CONTAINER

で調べることができるが、docker-compose で立ち上げたコンテナとかは専用のネットワークに所属するので、

docker inspect -f "{{.NetworkSettings.Networks.NETWORK.IPAddress}}" CONTAINER

とする必要があった。

動作確認したメモ

$ cat docker-compose.yml 
version: "2"
services:
  test:
    image: ubuntu
    command: tail -f /dev/null

$ docker-compose up -d
Creating network "test_default" with the default driver
Creating test_test_1

$ docker inspect -f '{{.NetworkSettings.Networks.test_default.IPAddress}}' test_test_1
172.23.0.2

$ docker-compose down
Stopping test_test_1 ... done
Removing test_test_1 ... done
Removing network test_default
30
28
1

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
30
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?