Unable to link containers

Hi to everybody!
I am new on the forum and also new with docker so please excuse me in advance for any bs I am going to say! :smiley:
I am having problems linking containers, right now I am trying to running etherpad-lit and I am following the exact commands given in the docker-hub page:

  1. docker run -d -e MYSQL_ROOT_PASSWORD=password --name ep_mysql mysql
  2. docker run -ti --link=ep_mysql:mysql -p 9001:9001 tvelocity/etherpad-lite

However I am facing with:

ERROR 2003 (HY000): Can’t connect to MySQL server on ‘mysql’ (113)

I am running docker on Fedora 22 and I have disabled selinux and followed the Fedora documentation for iptable rules but I still can’t have two containers to talk to each other.

any help? thx

Hello,

It looks like you are hitting a race condition. The tvelocity/etherpad-lite image doesn’t appear to attempt any retries if it can’t connect to mysql. The mysql image doesn’t come up immediately after you start the container.

I can reproduce your problem if I start the images in immediate succession:

docker run -d -e MYSQL_ROOT_PASSWORD=password --name ep_mysql mysql && docker run -ti --link=ep_mysql:mysql -p 9001:9001 tvelocity/etherpad-lite

If I start the mysql container, wait a few seconds, and then start the ethepad-lite container, it works.

I am also able to confirm that the mysql container is up by running this command:

docker run -it --link ep_mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'

/Jeff

Dear Jeff thank you for your reply…I tried your hints but I am still facing the same problem…

Running the command: docker run -it --link ep_mysql:mysql --rm mysql sh -c ‘exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"’

gives me the following error: ERROR 2003 (HY000): Can’t connect to MySQL server on ‘172.17.0.6’ (113)

And I waited some minutes before running etherpad…

I have also tried on a different machine and still the same error so I am starting to think that I have not configured something…

any hints?
thx

A little update…I have installed a litte centos docker image and tried to scan open ports on docker0 to check if I can reach the mysql docker container…and it seems that something is filtering the 3306 port as I got:

Starting Nmap 6.40 ( http://nmap.org ) at 2015-08-03 20:01 UTC
Nmap scan report for 172.17.0.2
Host is up (0.000050s latency).
All 1000 scanned ports on 172.17.0.2 are filtered

I have also tried to create iptables rules by:
iptables -t filter -A INPUT -p tcp -i docker0 --dport 3306 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp -o docker0 --dport 3306 -j ACCEPT

but nothing happened…I still have all the ports filtered…hints?? thx

What is the docker logs output of the mysql container?

docker run -d -e MYSQL_ROOT_PASSWORD=password --name ep_mysql mysql
docker logs -f ep_mysql

Check mysql bind to only localhost(127.0.0.1) ??