深度阅读

How to Use the Docker Commands To List, Start, Run and Stop Your Docker Containers

作者
作者
2023年08月22日
更新时间
15.45 分钟
阅读时间
0
阅读量

Docker replicates a specific operating environment on top of a host OS.Each environment is a “Container”.Managing containers is essential for working in containers.

The basic format for using docker is the following:

docker command [options]

List Docker Containers .

To list all running Docker containers:

docker ps

To list all containers, both running and stopped by .

docker ps –a

To list containers by their ID use –aq (quiet):

docker ps –aq

To list the entire file size of each containers, use –s (size):

docker ps –s

To list the latest created containers.

docker ps –l

Start Docker Container

The main command to launch or start is docker start:

docker start [options] container_id 

You can specify the container by either using its name or ID.

To create a new container from an image and start it.

docker run [options] image [command] [argument] 

To define theContainer name , use the -name option :

docker run ––name=Ubuntu_Test ubuntu:14.04

To start the containers in interactive mode, use the options -i and -t :

docker run –it ––name=Ubuntu_Test ubuntu:14.04

Instead of using -i or -t options, use the attach command.

docker attach container_id

Stop Docker Container

Use the docker stop command to stop.

docker stop [option] container_id

To stop all running containers.

docker stop $(docker ps –a –q)

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。