Here's the result when I type docker ps
:
I have 3 docker containers: webapps, redis and rabbitmq. I want to link container webapps to container redis and rabbitmq container. In non docker apps, mywebapps can send message to rabbitmq and write/read redis.
I tried using command like this
docker run --name rabbitmq -p 8080:80 --link webapps:nimmis/apache-php7 -d rabbitmq
but it does not work.
Here is my config.php on webapps where I am trying to send messages via rabbitmq:
define('HOST', 'localhost');
define('PORT', 5672);
I tried to change localhost with hostname
define('HOST', 'rabbitmq');
define('PORT', 5672);
Error message says connection refused
.
It seems that in my three containers needs to be configured in the same network namespace.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…