Connect from one Docker container to another

后端 未结 7 1682
故里飘歌
故里飘歌 2020-12-04 18:11

I want to run rabbitmq-server in one docker container and connect to it from another container using celery (http://celeryproject.org/)

I have rabbitmq running using

7条回答
  •  借酒劲吻你
    2020-12-04 19:13

    When you specify -p 5672, What docker does is open up a new port, such as 49xxx on the host and forwards it to port 5672 of the container.

    you should be able to see which port is forwarding to the container by running:

    sudo docker ps -a
    

    From there, you can connect directly to the host IP address like so:

    amqp://guest@HOST_IP:49xxx
    

    You can't use localhost, because each container is basically its own localhost.

提交回复
热议问题