Port mapping is not the only way to connect to another docker container.ĭocker has a connection system allows multiple containers together, sharing the connection information.ĭocker connection will create a parent-child relationship, the parent container in which you can see the information of the sub container.
The above example, the default is to bind tcp port, if you want to bind UPD ports, a port in the back plus / udp. So that we can access the container through the access port 127.0.0.1:5001 5002. In addition, we can specify the network address binding container, such as binding 127.0.0.1.
-p: inside the container port is bound to the specified host port.-P: Is mapped to the inside of the container port random high port on the host.We can also use the -p flag to specify the container port is bound to the host port. :~$ docker psĬONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESįce072cc88ce training/webapp "python app.py" 4 minutes ago Up 4 minutes 0.0.0.0:32768->5000/tcp grave_hopper We use the -P parameter to create a container, use docker ps port 5000 is bound to see a host port 32768. We created a python application container.
In front of us to achieve access to the network through the port is operating in the docker container services.