Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does docker close the container?

Shulou Source: shulou.com Published: 2022-06-01 10:34:00 10月01日 Update

This article mainly explains "how to close the container by docker". Interested friends may wish to take a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "docker how to close the container"!

Generally, we can use docker stop to terminate a running container. In addition, the container automatically terminates when the application specified in the docker container terminates.

For example, a container with only one terminal is started, and when a user exits the terminal through the exit command or Ctrl+d, the created container terminates immediately. The container that terminates the state can be seen with the docker ps-a command.

Or use the following steps to specify how to stop the docker service.

Step 1: check the version of our operating system. Different operating system versions have different ways to stop docker services. Use lsb_release-a to check the version number. Here, take centos 6.5 as an example.

Step 2: before shutting down the docker service, we use the docker ps command to check whether there is a container running. We need to stop the container first. Stopping the service directly may cause the container exception.

Docker ps-- view the container that is running

Docker stop container ID-- stop container

Step 3: since the operating system version queried above is centos 6.5, we use service docker stop to stop the container service (/ etc/init.d/docker stop is also available)

Change the way the service starts and shuts down after centos 7. You can use the command systemctl stop docker to shut down

Step 4: check the current container service status service docker status (or / etc/init.d/docker status)

View status on systemctl status docker-centos 7

At this point, I believe you have a deeper understanding of "how to close the container by docker". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Container service step command version operating system status system run content method being terminal learning query different practical deeper middle finger interest Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Huawei Redmi MariaDB macOS