首页 > 代码库 > [Docker] Run, Stop and Remove Docker Containers

[Docker] Run, Stop and Remove Docker Containers

In this lesson, we‘ll find out the basics of running Docker containers. We‘ll go over how to download images from Docker Hub, what happens when you stop containers, how to restart a container once it‘s been stopped, and also how to remove containers.

 

Run a container:

docker run mongo  // run the container, if container not exists, download from hub

This will output the console log in the command line

 

Another way to run docker is in the backage:

docker run -d mongo

 

To stop a container running:

docker stop <container id>

 

To varify there is not container running:

docker ps

 

List all the container regarelss running or not:

docker ps -a

 

Start an container:

docker start <container_id>

 

Remove an container:

docker rm <container_id>

Notice that container shoud be stop first, then you can remove it.

 

[Docker] Run, Stop and Remove Docker Containers