[root@docker01 ~]# docker run -d -p 80:80 nginx Unable to find image 'nginx:latest' locally latest: Pulling from library/nginx e7bb522d92ff: Pull complete 6edc05228666: Pull complete cd866a17e81f: Pull complete Digest: sha256:285b49d42c703fdf257d1e2422765c4ba9d3e37768d6ea83d7fe2043dad6e63d Status: Downloaded newer image for nginx:latest 8d8f81da12b5c10af6ba1a5d07f4abc041cb95b01f3d632c3d638922800b0b4d # 容器启动后,在浏览器进行访问测试
参数说明
参数
说明
run
创建并运行一个容器
-d
放入后台
-p
端口映射
nginx
镜像名称
查看当前主机镜像列表
1 2 3 4
[root@docker01 ~]# docker image list REPOSITORY TAGIMAGE ID CREATED SIZE centos latest ff426288ea90 3 weeks ago 207MB nginx latest 3f8a4339aadd 5 weeks ago 108MB
2.2 导出镜像
1 2 3 4 5 6
[root@docker01 ~]# docker image list REPOSITORY TAGIMAGE ID CREATED SIZE centos latest ff426288ea90 3 weeks ago 207MB nginx latest 3f8a4339aadd 5 weeks ago 108MB # 导出 [root@docker01 ~]# docker image save centos > docker-centos.tar.gz
3. 删除镜像
1 2 3 4
[root@docker01 ~]# docker image rm centos:latest [root@docker01 ~]# docker image list REPOSITORY TAGIMAGE ID CREATED SIZE nginx latest 3f8a4339aadd 5 weeks ago 108MB
4. 导入镜像
1 2 3 4 5 6 7
[root@docker01 ~]# docker image load -i docker-centos.tar.gz e15afa4858b6: Loading layer 215.8MB/215.8MB Loaded image: centos:latest [root@docker01 ~]# docker image list REPOSITORY TAGIMAGE ID CREATED SIZE centos latest ff426288ea90 3 weeks ago 207MB nginx latest 3f8a4339aadd 5 weeks ago 108MB