[Docker] Run, Stop and Remove Docker Containers

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[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的主要内容,如果未能解决你的问题,请参考以下文章

[DevOps] Set up and run a PostgreSQL instance locally with Docker Compose

docker学习笔记——Docker常用命令总结

Docker命令学习

docker-基础命令

docker相关操作

Increase ulimit in ubuntu and docker