Multiple docker containers as web server on a single IP

后端 未结 2 922
我寻月下人不归
我寻月下人不归 2020-12-07 23:33

I have multiple docker containers on a single machine. On each container is running a process and a web server that provides an API for the process.

My question is,

2条回答
  •  我在风中等你
    2020-12-07 23:52

    Only a single process is allowed to be bound to a port at a time. So running multiple containers means each will be exposed on a different port number. Docker can do this automatically for you by using the "-P" attribute.

    sudo docker run -P -t -i /
    

    You can use the "docker port" and "docker inspect" commands to see the actual port number allocated to each container.

提交回复
热议问题