Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Common Docker commands

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. View all mirrors

Docker image ls abbreviation: docker images

two。 View all running containers

Docker container ls abbreviation: docker ps

3. View all containers

Docker container ls-an abbreviation: docker ps-a

4. Delete Container

Docker rm container container ID abbreviation: docker rm container ID

5. Delete Mirror

Docker image rm image ID abbreviation: docker rmi image ID

6. If there are many containers to be deleted, list all the container ID

Docker container ls-a | awk {'print$1'} / / output the first column abbreviated: docker container ls-aq delete all containers: docker rm $(docker container ls-aq)

7. Delete all exited containers

Docker container ls-f "status=exited" / / list all exit containers abbreviated: docker ps-f "status=exited" docker container ls-f "status=exited"-Q / / list all exit containers ID abbreviation: docker ps-f "status=exited"-qdocker rm $(docker container ls-f "status=exited"-Q) abbreviation: docker rm $(docker ps-f "status=exited"-Q)

8. Create a container by mirroring

Docker run-- name-d-p 8080 ID explains:-- name gives the container an alias-d for background operation-p container port and host port mapping

9. Create an image by the container (because the container may change during use, for example: a centos container with the vim plug-in installed)

Docker container commit abbreviation: docker commit Note: this is not recommended

10. Create a mirror through Dockerfile

Docker image build abbreviation: docker build

11. Enter a container that is running

Docker exec-it container name / bin/bash (or / bin/sh)

twelve。 Copy the files in the container to the host

# docker cp container name: the path of the file to be copied in the container should be copied to the corresponding path of the host docker cp nginx:/usr/share/nginx/nginx.tar / usr/local

13. Copy the files from the host to the container

# File path to be copied by docker cp Container name: to copy to the corresponding path docker cp / usr/local/nginx.tar nginx:/usr/share in the container

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report