Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I've already seen posts showing how to remove exited containers listed with docker ps -q -f status=exited, but I also want to clean up 'created' but not 'running' containers. Is it safe to remove containers with the 'created' status, or is there a downside to this?

like image 531
Blake Avatar asked Sep 26 '22 10:09

Blake


1 Answers

Docker containers with created status are containers which are created from the images, but never started. Removing them has no impact as you would not have run any process within the container and causing a change in the state of the created container, in the later case requires to be committed. This is generally done to speed up starting the container and making sure all the configuration is kept ready.

Refer Docker Docs

The docker create command creates a writeable container layer over the specified image and prepares it for running the specified command. The container ID is then printed to STDOUT. This is similar to docker run -d except the container is never started. You can then use the docker start command to start the container at any point.

This is useful when you want to set up a container configuration ahead of time so that it is ready to start when you need it. The initial status of the new container is created.

like image 193
askb Avatar answered Sep 30 '22 06:09

askb