Skip to content

Instantly share code, notes, and snippets.

@mapk0y
Last active June 29, 2017 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapk0y/cf40f5bd77bffe73ffd3449ba99e2df7 to your computer and use it in GitHub Desktop.
Save mapk0y/cf40f5bd77bffe73ffd3449ba99e2df7 to your computer and use it in GitHub Desktop.
一つのディレクトリの中の複数の compose file での名前解決
$ tree
.
├── compose-a.yml
└── compose-b.yml
$ cat compose-a.yml 
version: '2'

services:
    a:
        image: debian
        tty: true
        command: bash
$ cat compose-b.yml 
version: '2'

services:
    b:
        image: debian
        tty: true
        command: ping a
$ docker-compose -f compose-a.yml up -d
Creating network "multipulfile_default" with the default driver
Creating multipulfile_a_1
$ docker-compose -f compose-a.yml ps
      Name         Command   State   Ports 
------------------------------------------
multipulfile_a_1   bash      Up            
$ docker-compose -f compose-b.yml up -d
WARNING: Found orphan containers (multipulfile_a_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Recreating multipulfile_b_1
$ docker-compose -f compose-b.yml logs
Attaching to multipulfile_b_1
b_1  | PING a (172.18.0.2): 56 data bytes
b_1  | 64 bytes from 172.18.0.2: icmp_seq=0 ttl=64 time=0.069 ms
b_1  | 64 bytes from 172.18.0.2: icmp_seq=1 ttl=64 time=0.104 ms
b_1  | 64 bytes from 172.18.0.2: icmp_seq=2 ttl=64 time=0.103 ms
b_1  | 64 bytes from 172.18.0.2: icmp_seq=3 ttl=64 time=0.100 ms
b_1  | 64 bytes from 172.18.0.2: icmp_seq=4 ttl=64 time=0.103 ms
b_1  | 64 bytes from 172.18.0.2: icmp_seq=5 ttl=64 time=0.086 ms
b_1  | 64 bytes from 172.18.0.2: icmp_seq=6 ttl=64 time=0.101 ms
b_1  | 64 bytes from 172.18.0.2: icmp_seq=7 ttl=64 time=0.103 ms
$ docker-compose -f compose-a.yml exec a ping b
PING b (172.18.0.3): 56 data bytes
64 bytes from 172.18.0.3: icmp_seq=0 ttl=64 time=0.079 ms
64 bytes from 172.18.0.3: icmp_seq=1 ttl=64 time=0.148 ms
^C--- b ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.079/0.113/0.148/0.035 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment