In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
What this article shares with you is about how to modify the docker container as soon as it starts. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
How to modify the exit of the docker container as soon as it starts? Novice docker users often encounter the problem of quitting as soon as they start, and often understand Docker as a virtual machine, thinking that starting Docker is to start a virtual machine, and they don't understand the difference between foreground and background.
First of all, if you encounter such problems, you should check the log and the exit code of the main process of the container.
Check the container log:
Docker logs
Check the container exit code:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMEScc2aa3f4745f ubuntu "/ bin/bash" 23 hours ago Exited (0) 22 hours ago clever_lewin25510a2cb171 twang2218/gitlab-ce-zh:8.15.3 "/ assets/wrapper" 2 days ago Exited (127) 2 days ago determined_mirzakhani
In the STATUS column, you can see what the exit code is.
If you see Exited (127), it's probably due to excessive memory that triggered Out Of Memory and then was forcibly terminated; if you see Exited (0), it means that the container main process exited normally; if it's anything else, you should check the container log.
Beginners of Docker often don't understand how they can quit since it's normal. Docker is not a virtual machine, the container is just a process. Therefore, when docker run is executed, all you actually do is start a process, and if the process exits, the container naturally terminates.
Why the process exited:
If you are executing a command to start a background service program such as service nginx start, you are treating Docker as a virtual machine. Docker starts the process, so the so-called background service should be placed in the foreground, for example, the nginx-g 'daemon off;' should launch the application directly in the foreground.
If you find / bin/bash in the COMMAND column, think of Docker as a virtual machine. COMMAND should be an application, not an interactive interface, and the container does not need an interactive interface. In addition, if you want an interactive interface with / bin/bash, it must also be provided with input and terminal, so you must add the-it option, such as docker run-it ubuntu / bin/bash
The above is how to modify the exit of the docker container as soon as it starts. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.