
Docke镜像
运行容器时,如果使用的镜像在本地中不存在,docker就会自动从 docker镜像仓库中下载,默认是从 Docker Hub
公共镜像源下载。

下面就介绍下相关命令的使用。
列出镜像列表
$ docker images
执行效果:

各个选项的解释:
选项 | 说明 |
---|---|
REPOSITORY | 表示镜像的仓库源 |
TAG | 镜像的标签 |
IMAGE ID | 镜像ID |
CREATED | 镜像创建时间 |
SIZE | 镜像大小 |
获取新的镜像
$ docker pull 镜像名字
例如:docker pull nginx:latest
执行效果:

注意:image的名字可以从docker hub官网查看
启动容器
$ docker run --name nginx-test -p 8080:80 -d nginx
参数解释:
参数 | 说明 |
---|---|
--name nginx-test | 容器名称。 |
-p 8080:80 | 端口进行映射,将本地 8080 端口映射到容器内部的 80 端口。 |
-d nginx | 设置容器在在后台一直运行。 |
执行结果:

通过网络查看服务器是否起来:
-
打开网页输入127.0.0.1:8080
image.png
查找镜像
可以从 Docker Hub网站来搜索镜像,也可以使用 docker search 命令来搜索镜像。
$ docker search nginx
执行效果:

删除镜像
顾名思义:
$ docker rmi hello-world
创建镜像
创建镜像有两种方式:
1、从已经创建的容器中更新镜像,并且提交这个镜像
2、使用 Dockerfile 指令来创建一个新的镜像
后文在慢慢讨论,今天的学习就先到这里了。^_^
网友评论