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.
-p
along with--link
is nothing but useless.-p 8080:80
will tell the docker proxy to make the port 8080 in your container exposed to the port 80 on your system. So if you type-p 6379:6379
as well for your redis container, your php app can use redis just by connecting tolocalhost:6379
.