I have the following compose file:
mysql:
image: mariadb:10
environment:
MYSQL_ROOT_PASSWORD: xxx
server:
image: php:5.6-apache
links:
- mysql:mysql
Now when I run
docker-compose create && docker-compose start
And run
docker exec -it ..._server_1 ping mysql
it returns
ping: unknown host
(though docker exec -it ..._server_1 ping < IP-Address of container> works)
If I instead create the containers with docker-compose up command and ping the mysql-container, it works!
What is the difference between these commands?
The difference is that create doesn't start the containers - it only creates them. That's why the mysql container isn't reachable: it's not running.
ok, but I also started it using docker-compose start and they are both running:
1e0deca3841a php:5.6-apache "apache2-foreground" 4 minutes ago Up 4 minutes 80/tcp linktest_server_1
c60abd52a642 mariadb:10 "/docker-entrypoint.s" 4 minutes ago Up 4 minutes 3306/tcp linktest_mysql_1
And the problem persists:
$ docker exec -it linktest_server_1 ping mysql
ping: unknown host
I have attached the output of docker inspect linktest_server_1 and the relevant entry is "Links":null:
link-test.txt
Versions:
Docker version 1.10.3, build 20f81dd
docker-compose version 1.6.2, build 4d72027
+1
We're now deprecating docker-compose create. Its replacement, docker-compose up --no-start should create all the necessary resources for services to find one another.
Unfortunately I also must state that "docker-composer up --no-start" still does not work.
In "docker inspect _containerId_" I see:
"Links": null
It doesn't matter if I later start the container with "docker-composer up" or "docker-composer start" - the "Links" are empty and /etc/hosts does not contain appropriate entries.
Though, when I start directly with "docker-composer up" all works fine. The "Links"-attribute in "docker inspect" is filled, /etc/hosts is fine and name-resolving works.
There _is_ a bug - and there is _no_ difference between "docker-compose create" and "docker-compose up --no-start"
Most helpful comment
ok, but I also started it using
docker-compose startand they are both running:And the problem persists:
I have attached the output of
docker inspect linktest_server_1and the relevant entry is"Links":null:link-test.txt
Versions: