Docker 命令基本语法

## 输出 Docker CLI 命令列表
docker
docker container --help

## 输出 Docker 版本 or 信息
docker --version
docker version
docker info

## 执行 Docker 镜像
docker run hello-world

##  显示 Docker 镜像列表
docker image ls

## List Docker containers (running, all, all in quiet mode)
sudo docker container ls         ##列出正在执行的container
sudo docker container ls --all   ##列出所有执行过的container记录
sudo docker container ls -a -q   ##列出所有的container ID
docker build -t friendlyhello .  # 用当前目录的Dockerfile创建一个名字为friendlyhello的镜像
docker run -p 4000:80 friendlyhello  # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyhello         # Same thing, but in detached mode 内部运行
docker container ls                                # List all running containers
docker container ls -a             # List all containers, even those not running
docker container stop <hash>           # Gracefully stop the specified container
docker container kill <hash>         # Force shutdown of the specified container
docker container rm <hash>        # Remove specified container from this machine
docker container rm $(docker container ls -a -q)         # Remove all containers
docker image ls -a                             # List all images on this machine
docker image rm <image id>            # Remove specified image from this machine
docker image rm $(docker image ls -a -q)   # Remove all images from this machine
docker login             # Log in this CLI session using your Docker credentials 本地登录
docker tag <image> username/repository:tag  # Tag <image> for upload to registry 上传到注册表
docker push username/repository:tag            # Upload tagged image to registry  上传到云
docker run username/repository:tag                   # Run image from a registry  从云端下载运行
sudo docker ps  # 查看运行状态
sudo docker ps  -all  # history 运行状态
                      #与container 类似
docker stack ls                                            # List stacks or apps Services List
docker stack deploy -c <composefile> <appname>  # Run the specified Compose file 运行指定的Compose 文件
docker service ls                 # List running services associated with an app
docker service ps <service>                  # List tasks associated with an app
docker inspect <task or container>                   # Inspect task or container
docker container ls -q                                      # List container IDs
docker stack rm <appname>                             # Tear down an application docker swarm leave --force      # Take down a single node swarm from the manager





  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值