You can use docker attach to enter the Docker container.
(Recommended learning: docker tutorial)
The details are as follows:
Docker provides the attach command to enter the Docker container.
Next we create a daemon Docker container, and then use the docker attach command to enter the container.
$ sudo docker run -itd ubuntu:14.04 /bin/bash
Then we use docker ps to view the container information, and then use docker attach to enter the container
$ sudo docker attach 44fc0f0582d9
You can see that we have entered the container.
But there is a problem with using this command. When multiple windows use this command to enter the container at the same time, all windows will be displayed simultaneously. If one window is blocked, other windows will no longer be able to operate. Come on, let's demonstrate. Open two windows and use the attach command to enter the same container. As shown below:
# Next we only operate in the first window. You can see that the operations in the first window are synchronized to the second window, as follows :
For this reason, the docker attach command is not suitable for production environments. You can use this command when developing your own applications.
The above is the detailed content of How to enter docker container. For more information, please follow other related articles on the PHP Chinese website!