Docker Commands
...March 20, 2020About 1 min
Docker Commands
官方文档:https://docs.docker.com/engine/reference/commandline
docker info
Display system-wide information
docker inspect
Return low-level information on Docker objects
docker inspect [OPTIONS] NAME|ID [NAME|ID...]
docker ps
查看运行的 docker 容器
docker images
查看 docker 镜像
docker rm
Remove one or more containers
docker rm [OPTIONS] CONTAINER [CONTAINER...]
# 删除所有已经停止的容器
docker rm $(docker ps -a -q)
docker rmi
Remove one or more images
docker rmi [OPTIONS] IMAGE [IMAGE...]
docker start
Start one or more stopped containers
docker start [OPTIONS] CONTAINER [CONTAINER...]
docker stop
Stop one or more running containers
docker stop [OPTIONS] CONTAINER [CONTAINER...]
docker restart
Restart one or more containers
docker restart [OPTIONS] CONTAINER [CONTAINER...]
docker port
List port mappings or a specific mapping for the container
docker port CONTAINER [PRIVATE_PORT[/PROTO]]
docker run
Run a command in a new container
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
docker exec
Run a command in a running container
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
进入 docker 容器
docker exec -it container_name /bin/bash
docker exec -it ubuntu_bash bash
执行 docker 容器里的命令
docker exec -ti my_container sh -c "echo a && echo b"
# 解压文件
docker exec -it container_name tar -vxf a.tar
# 使用docker容器的root用户执行
docker exec -u root <container> <command>
docker cp
Copy files/folders between a container and the local filesystem
docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
docker commit
Create a new image from a container’s changes
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
docker build
Build an image from a Dockerfile
docker build [OPTIONS] PATH | URL | -
What do you think?
- 0
- 0
- 0
- 0
- 0
- 0
Powered by Waline v3.3.2