Home  >  Article  >  Operation and Maintenance  >  How to enter docker container

How to enter docker container

王林
王林forward
2020-06-30 17:58:213491browse

How to enter docker container

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.

How to enter 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

How to enter docker container

Then we use docker ps to view the container information, and then use docker attach to enter the container

$ sudo docker attach 44fc0f0582d9

How to enter docker container

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:

How to enter docker container

# 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 :

How to enter docker container

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete