根据搜索的文献,官网的文档,列举了使用docker时常用的一些命令
查看docker基本信息
1 2 3 4 5 6 7 8
| docker --version docker-compose --version docker-machine --version docker version docker info docker logs service docker status sudo service docker start|stop
|
检查
1 2 3 4
| docker ps docker ps -a docker run hello-world docker inspect <task or container>
|
镜像(image)操作
1 2 3 4 5 6 7 8 9 10 11
| docker build -t <image-name> . docker images docker image ls -a docker image rm <image id> docker image rm $(docker image ls -a -q) docker rmi [image-id/image-name] docker tag <image> <username>/<repository>:<tag> docker push <username>/<repository>:<tag> 上传后访问地址:https://cloud.docker.com/swarm/followtry/repository/docker/followtry/demo/general docker pull <username>/<repository> docker run username/repository:tag
|
容器(container)操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| docker container ls docker container ls -a docker container ls -q docker container stop <hash> docker container kill <hash> docker container rm <hash> docker container rm $(docker container ls -a -q) docker run -d -p 8080:80 --name webserver nginx docker stop <containerid/container-name> docker start <containerid/container-name> docker port <containerid/container-name> docker logs -f <containerid/container-name> docker top <containerid/container-name> docker inspect <containerid/container-name> docker rm <hash> docker rm $(docker ps -a -q) docker kill <hash>
|
参考文献 https://docs.docker-cn.com/
参考文献 Docker常用命令