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 the boot container

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

Share

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

This article mainly introduces how Docker enters the startup container, which is very detailed and has a certain reference value. Interested friends must finish reading it!

This document describes how Docker can enter the launch container and share it with you. The details are as follows:

When using the-d parameter, the container will enter the background after startup, and the user cannot see the information in the container and cannot operate.

At this time, if you need to enter the container to operate, there are a variety of ways, including the use of official attach or exec commands, as well as third-party nsenter tools.

1. Attach command

The attach command is a command that comes with Docker. The command format is:

Docker attach [- detach-keys [= [] [- no-stdin] [- sig-proxy [= true]] Container

Three main options are supported:

-detach-keys [= []]: specifies the shortcut key sequence to exit attach mode. Default is CTRL-p CTRL-q.

-no-stdin=true | false: whether to disable standard input. The default is to keep it on.

-sig-proxy=true | false: whether the system signal received by the agent is sent to the application process. Default is true.

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

2. Exec command

Docker provides a more convenient exec command from version 1.3.0 to execute arbitrary commands directly within the container. The basic format of the command is:

Docker exec [- d |-detach] [- detach-keys [= []] [- I |-interactive] [- privileged] [- t |-tty] [- u |-user [= USER]] CONTAINER COMMAND [ARG …] .

The more important parameters are:

| false: open standard input to accept user input commands. Default is false. |

-privileged=true | false: whether to give high permissions to execute commands. Default is false.

-tjinghttyassigned true | false: assigns pseudo terminals. Default is false.

-umam ID username = "": the user name or user name that executes the command.

For example, go to the container you just created and start a bash:

As you can see, a bash terminal is open, and users can easily interact with the container without affecting other applications in the container.

Keep the standard input open by specifying the-it parameter, and assign a pseudo terminal. Performing operations on the container through the exec command is the most recommended way.

The above is all the contents of the article "how to get into the startup container for Docker". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Original link: http://blog.csdn.net/u011641865/article/details/72472215

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