查看本地docker镜像
[root@bogon ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
imported mysql c3f6dde78a19 About a minute ago 192.5 MB
docker.io/centos 7 328edcd84f1b 5 weeks ago 192.5 MB
删除镜像
docker rmi c3f6dde78a19
查看所有的容器
docker ps -a
[root@bogon ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1615de430c60 centos:7 "/bin/bash" 27 hours ago Up 27 hours 0.0.0.0:3307->3306/tcp compassionate_carson
e863bfaecaaa centos:7 "/bin/bash" 27 hours ago Up 27 hours grave_raman
94c674bd6899 centos:7 "/bin/bash" 2 days ago Exited (0) 27 hours ago agitated_galileo
查看所有的运行的容器
docker ps
[root@bogon ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1615de430c60 centos:7 "/bin/bash" 27 hours ago Up 27 hours 0.0.0.0:3307->3306/tcp compassionate_carson
e863bfaecaaa centos:7 "/bin/bash" 27 hours ago Up 27 hours grave_raman
创建新的容器
docker create -it centos:7(该命令创建容器处于静止状态需要start开启)
docker run -it centos:7(该命令不仅创建了容器而且运行了)
开启某个docker容器
docker start centos:7 /bin/bash
docker start 94c674bd6899(该容器已创建,关闭状态,重新开启)
进入某个docker容器(该容器在后台运行中)
docker exec -it 1615de430c60 /bin/bash
创建新的容器并把docker容器的3306端口映射成主机的3307端口
docker run -it -p 3307:3306 centos:7 /bin/bash
关闭某个容器
docker stop 1615de430c60
docker kill 1615de430c60
删除某个容器
docker rm 1615de430c60
导出某个容器
docker export 1615de430c60 > mysql.tar
导入tar包作为镜像
cat mysql.tar |docker import - imported:mysql
[root@bogon ~]# cat mysql.tar |docker import - imported:mysql
sha256:c3f6dde78a19ad3553833b2a15516a7bf204f70e054c2e10350b0f15873600e3
[root@bogon ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
imported mysql c3f6dde78a19 About a minute ago 192.5 MB
docker.io/centos 7 328edcd84f1b 5 weeks ago 192.5 MB
运行docker命令时出现Cannot connect to the Docker daemon. Is the docker daemon running on this host?
解决:Service docker start