Is it safe to delete Docker containers listed with `docker ps -f status = created`?

I have already seen posts showing how to remove the displayed containers listed in docker ps -q -f status=exited , but I also want to clear the containers "created" but not "started". Is it safe to delete containers with the "created" status or are there any disadvantages?

+5
source share
2 answers

Docked containers with created status are containers created from images but never launched. Removing them does not affect, since you should not start any process in the container and cause a change in the state of the created container, in the latter case it is required that it be committed. This is usually done to speed up the launch of the container and ensure that the entire configuration is ready.

Refer to Docker Docs

The create docker command creates a loadable container layer on top and prepares it to run the specified command. The container identifier is then printed in STDOUT. This is similar to running dockers -d, except that the container does not start. Then you can use the docker launch command to start the container anywhere.

This is useful if you want to configure the container ahead of time so that it is ready to start when you need it. Initial will create the status of a new container.

+4
source

There are two possibilities for a container in the created state:

  • As explained by the dasker @askb container created from the image using the create docker command, the create command will
  • A docker container created by the run command but not capable of starting. There are several reasons here, but the simplest is a docker container with port mapping for already bound

To answer the question, in both cases their removal is safe.

The way to play the docker container in the created state using the launch command:

 docker pull loicmathieu/vsftpd docker run -p 621:21 -d loicmathieu/vsftpd ftp docker run -p 621:21 -d loicmathieu/vsftpd ftp 

Then docker ps -a will give you something like

 CONTAINER ID IMAGE COMMAND CREATED STATUS e60dcd51e4e2 loicmathieu/vsftpd "/start.sh ftp" 6 seconds ago Created 7041c77cad53 loicmathieu/vsftpd "/start.sh ftp" 16 seconds ago Up 15 seconds 
0
source

Source: https://habr.com/ru/post/1234256/


All Articles