Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does docker enter a running container

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Today, what the editor shares with you is how docker enters the running container. I believe many people don't know much about it. In order to make you understand better, I summed up the following contents for you. Let's look down together. I'm sure you'll get something.

There are three ways we want to enter the container we are using. They are:

1) docker attach [Container name]: attach is similar to VNC, and the operation is displayed in each container interface. Therefore, all operations entering the container are displayed synchronously, but when exit exits the container, the container also stops, so this method is not recommended.

2) docker exec-it [container name / id]: enter the container after executing a single command, which is not recommended, although the container will not stop after exit exits.

3) nsenter-t [container pid]-m-u-I-n-p: enter the container in this way, provided that you must know the PID number of the container before it can be executed. You can obtain the PID number of the container through docker inspect-f {{. State. Pid}} [container name].

Expansion: about entering containers

When using the-d parameter, the container will enter the background after startup. There are many ways to enter the container to operate, including using the docker attach command or the nsenter command.

Use docker attach to enter the container

1.docker attach allows us to enter the background process.

2.-sig-proxy=false does not use the container to forward signals, which allows us to use ctrl-c to exit, execute dockerps view and run in the background.

But using the attach command is sometimes inconvenient. When multiple windows are attach to the same container at the same time, all windows are displayed synchronously. When one window is blocked by a command, other windows cannot perform the operation.

You can also execute docker exec to enter the running container

Docker exec-it container ID/ name / bin/bash

The above command returns a command interface, and exec stands for running the command directly in the container

On how to enter the running container of docker is shared here, I hope that the above content can have a certain reference value for you, you can learn to apply. If you like this article, you might as well share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report