Skip to content

Instantly share code, notes, and snippets.

@mapk0y
Last active August 27, 2016 03:48
Show Gist options
  • Save mapk0y/a35455428ae6422378044e3c2a79c11d to your computer and use it in GitHub Desktop.
Save mapk0y/a35455428ae6422378044e3c2a79c11d to your computer and use it in GitHub Desktop.
docker-compose と 名前解決

利用した docker-compose.yml

version: '2'

services:
    bar:
        image: alpine
        command: sh -xc 'ping foo'
    foo:
        image: alpine
        command: sh -xc 'ping bar'

docker/docker-compose のバージョン

  • docker: 1.12.1
  • docker-compose: 1.8.0 (pip で install)
$ docker version
Client:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:02:53 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:02:53 2016
 OS/Arch:      linux/amd64
 
$ docker-compose -v
docker-compose version 1.8.0, build 94f7016

テスト

$ docker-compose up
Recreating nameresolv_foo_1
Recreating nameresolv_bar_1
Attaching to nameresolv_foo_1, nameresolv_bar_1
foo_1  | + ping bar
bar_1  | + ping foo
bar_1  | PING foo (172.20.0.2): 56 data bytes
foo_1  | PING bar (172.20.0.3): 56 data bytes
bar_1  | 64 bytes from 172.20.0.2: seq=0 ttl=64 time=0.135 ms
foo_1  | 64 bytes from 172.20.0.3: seq=0 ttl=64 time=0.076 ms
foo_1  | 64 bytes from 172.20.0.3: seq=1 ttl=64 time=0.112 ms
bar_1  | 64 bytes from 172.20.0.2: seq=1 ttl=64 time=0.140 ms
bar_1  | 64 bytes from 172.20.0.2: seq=2 ttl=64 time=0.101 ms
foo_1  | 64 bytes from 172.20.0.3: seq=2 ttl=64 time=0.101 ms
foo_1  | 64 bytes from 172.20.0.3: seq=3 ttl=64 time=0.127 ms
bar_1  | 64 bytes from 172.20.0.2: seq=3 ttl=64 time=0.127 ms
bar_1  | 64 bytes from 172.20.0.2: seq=4 ttl=64 time=0.152 ms
foo_1  | 64 bytes from 172.20.0.3: seq=4 ttl=64 time=0.152 ms
foo_1  | 64 bytes from 172.20.0.3: seq=5 ttl=64 time=0.128 ms
bar_1  | 64 bytes from 172.20.0.2: seq=5 ttl=64 time=0.128 ms
foo_1  | 64 bytes from 172.20.0.3: seq=6 ttl=64 time=0.126 ms
bar_1  | 64 bytes from 172.20.0.2: seq=6 ttl=64 time=0.126 ms
foo_1  | 64 bytes from 172.20.0.3: seq=7 ttl=64 time=0.149 ms
bar_1  | 64 bytes from 172.20.0.2: seq=7 ttl=64 time=0.149 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment