您的位置:首页 > 运维架构 > Docker

Docker 命令基本语法

2018-03-13 15:20 381 查看
## 输出 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 &l
4000
t;appname>                             # Tear down an application docker swarm leave --force      # Take down a single node swarm from the manager
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: