Home > Operation and Maintenance > Docker > Docker container does not stop exiting

Docker container does not stop exiting

WBOY
Release: 2022-02-07 10:46:05
Original
5767 people have browsed it

In docker, you can press the "Ctrl P Q" key to exit the container without stopping; if you exit the container after entering the docker container, the container will become Exited. "Ctrl P Q" will exit the container and the container will not stop. will stop.

Docker container does not stop exiting

The operating environment of this tutorial: linux7.3 system, docker-1.13.1 version, Dell G3 computer.

How does the docker container stop exiting?

If you exit the container after entering the docker container, the container will become Exited. So how do you exit the container so that the container does not close?
If you want to exit normally without closing the container, please press Ctrl P Q to exit the container. This is very important, please remember!

The following example exits the container but does not close the container

Docker container does not stop exiting

In fact, we can configure it when starting the container and add the -d parameter to start the container , of course, this command is only limited to starting new containers, starting closed containers is not allowed.

Tips 1
docker run -d: Run the container in the background and return the container ID

The following example uses docker -d to start the container and exit

Docker container does not stop exiting

Here you may find that the container is still dead after using the -d command to exit. A hands-on friend may find that just using docker run -d to start the container is also dead

What you actually need to understand here is the running mechanism of the container. The Docker container runs in the background and must have a foreground process. Here we let the container have a foreground program to run, so that the container can survive after startup with -d

Docker container does not stop exiting

I use nohup to run a process in the background that pings Baidu every 1000 seconds. In addition, you can also use "while true; do echo hello world; sleep 1; done", unlimited Output hello world.

In addition, even if there is a process running in the background, if you enter the container and enter exit to exit, the running of the container will still be terminated, please bear in mind.

Recommended learning: "docker video tutorial"

The above is the detailed content of Docker container does not stop exiting. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template