1.

How do you prune data in a Docker?

Answer»

Docker provides a system prune command to remove stopped containers and dangling IMAGES.Dangling images are the ones which are not attached to any CONTAINER.

Run the prune command as below:

docker system prune

WARNING! This will remove:

  • all stopped containers
  • all networks not used by at least one container
  • all dangling images
  • all dangling build cache

Are you SURE you want to CONTINUE? [y/N]

There is also a better and controlled way of removing containers and images using the command:

Step 1: Stop the containers

docker stop <container_id>

Step 2: Remove the stopped container

docker rm container_id docker rm 6174664de09d

Step 3: Remove the images, first stop the container using those images and then

docker rmi <image_name>:[<tag>]

--GIVE image name and tag

docker rmi ubuntu:1.0

--give the image id

docker rmi 4431b2a715f3


Discussion

No Comment Found