Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

docker
remov
contain
container

How to remove a Docker container

Educative Answers Team

Removing a Docker container can easily be done by following these steps:

  • Use the docker ps command with the -a flag to locate the name or ID of the container(s) you want to remove:
docker ps -a
  • Run the following command and replace <ID> by the ID of the container that you want to remove:
docker rm <ID>
  • Multiple containers can also be removed with the command above:
docker rm <ID1> <ID2>

You can also automatically remove a container when it exits. This is useful if you know, while creating a container, that you will not need it afterward. The ​following command will run the container and automatically remove it upon exit:

docker run --rm image_name

RELATED TAGS

docker
remov
contain
container
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring