1 机器重启之后,需要开启docker:
sudo service docker start
2 然后开启daemon 监听:
sudo dockerd daemon
或者
sudo dockerd
3 打开/关闭/重启 docker:
sudo service docker start/stop/restart
4 查看 docker 状态:
$ sudo service docker status
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/docker.service.d
└─override.conf
Active: inactive (dead) (Result: exit-code) since Sun 2018-06-17 10:47:43 CST; 1 weeks 1 days ago
Docs: https://docs.docker.com
Process: 3135 ExecStart=/usr/bin/dockerd --host=fd:// --add-runtime=nvidia=/usr/bin/nvidia-container-runtime (code=exited, status=1/FAILURE)
Main PID: 3135 (code=exited, status=1/FAILURE)
5 删除镜像 image
docker image rm [OPTIONS] IMAGE [IMAGE...]
--force , -f Force removal of the image
--no-prune Do not delete untagged parents
6 删除容器
docker rm [OPTIONS] CONTAINER [CONTAINER...]
-f :通过SIGKILL信号强制删除一个运行中的容器
-l :移除容器间的网络连接,而非容器本身
-v :-v 删除与容器关联的卷
强制删除容器db01、db02
docker rm -f db01 db02
移除容器nginx01对容器db01的连接,连接名db
docker rm -l db
删除容器nginx01,并删除容器挂载的数据卷
docker rm -v nginx01
# 批量删除none的镜像
sudo docker rmi -f $(docker images | grep "none" | awk '{print $3}')
7 重命名镜像
docker tag IMAGEID(镜像id) REPOSITORY:TAG(仓库:标签)
8 docker加载新的镜像后repository和tag名称都为none的解决方法
docker tag [image id] [name]:[版本]
9. 构建并指定 image 的名称和版本号。
docker build . -t xxx/yyy:v1
10. 不使用cache 构建
docker build --no-cache=true .
11 保存与提交
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
$ docker commit c3f279d17e0a svendowideit/testimage:version3
f5283438590d
$ docker images
REPOSITORY TAG ID CREATED SIZE
svendowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB