What is the reason why docker container exits automatically?

WBOY
Release: 2022-04-14 18:48:53
Original
13806 people have browsed it

The reasons why the docker container will automatically exit: 1. The docker container does not have a foreground process, and the container will think it is idle, so it will automatically exit; 2. The commands run by the container are not commands that are always suspended (such as top, tail, loop etc.), so it will exit automatically.

What is the reason why docker container exits automatically?

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

What is the reason why the docker container automatically exits?

Why docker exits as soon as it is started

It is because there is no command that can support the persistent running of docker.

Exit reason

1. The docker container must have a foreground process to run. If there is no foreground process to execute, the container will think it is idle and will exit on its own

2. If the commands run by the container are not those that have been suspended (running top, tail, loop, etc.), they will automatically exit

3. This is a mechanism problem of docker

Solution:

docker run -dit docker.elastic.co/elasticsearch/elasticsearch:5.6.16 /bin/bash
Copy after login

Add the -it parameter to run interactively

Add the -d parameter to run in the background

This way you can start a program that always stays in the background. docker container.

Recommended learning: "docker video tutorial"

The above is the detailed content of What is the reason why docker container exits automatically?. 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