启动docker:
systemctl start docker
systemctl start docker.service
service docker status
查看启动日志:
cat /var/log/messages
查看docker内运行的容器:
docker ps
启动指定容器:
docker run -it ubuntu
停止指定ID的容器:
docker stop 容器ID
查看docker启动状态:
systemctl status docker
service docker status
停止docker:
systemctl stop docker
重启docker:
systemctl restart docker
service docker restart
#
镜像相关
查看镜像:
docker images
docker image ls
搜索镜像:
docker search nginx
docker search --filter=is-official=true nginx
docker search --filter=stars=4 nginx
docker search --filter=stars=5 tensorflow
拉取镜像:
docker pull mysql
删除镜像:
docker rmi ubuntu:latest
docker rmi ubuntu
docker rmi -f ubuntu:18.04
清除临时镜像文件:
docker image prune
删除未使用的镜像文件:
docker image prune -a
创建镜像:
docker [container] commit -m "Added a new file" -a "Docker Newbee" a925cb40b3f0 test:0.1
docker commit -m "addid a new file" -a "Docker Newbee" 3e3337220519 test:0.1
#
容器相关
创建容器:
docker create -it ubuntu:latest
启动容器:
docker start ccb
运行(新建并启动)容器:
docker run ubuntu:18.04 echo 'hello! I am here!'
守护态运行容器:
docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
查看运行的容器:
docker ps
dcoker ps -a
查看容器输出:
docker logs b16
docker logs --tail="10" b1
进入容器:
docker attach c3
docker exec -it 9b /bin/bash
暂停/恢复容器:
docker pause b1
docker unpause b1
终止容器:
dcoker stop b1
dcoker stop -t 0 b1
重启容器:
docker restart 19
docker restart -t 0 19
删除容器:
docker rm 23ded4134881
清除所有停止容器:
docker container prune
docker container prune -f
查看容器资源占用:
docker stats
docker stats 1b
查看容器内进程:
docker top 1b
产看容器详情:
docker container inspect 1b
#
Ubuntu相关
拉取指定版本:
docker pull ubuntu:18.04
拉取最新版本:
docker pull ubuntu
运行ubuntu:
docker run -it ubuntu:18.04 bash
docekr run -it ubuntu
测试运行结果:
echo "hello world"
退出:
exit