给registry安排mirrors
Docker daemon中加上
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com" ]
registry.docker-cn.com这个是官方的中国镜像但好像不好用,还是ustc的好用。
Image和contianer之间的关系
Image是镜像,更多偏向于一个环境包,这个环境包可以移动到任意的Docker平台中去运行。
镜像提供容器运行时所需的程序、库、资源、配置等文件外,还包含了一些为运行时准备的一些配置参数(如匿名卷、环境变量、用户等)
一个镜像可以启动任意多个容器(contianer)
what is a container? Simply put, a container is simply another process on your machine that has been isolated from all other processes on the host machine.
肯定先有image后有container,那如何创建Image镜像?
使用DockerFile,切换到dockerfile所在的根目录,docker build -t getting-started .
-t flag tags our image. Think of this simply as a human-readable name for the final image.
we named the image getting-started
The .
at the end of the docker build
command tells that Docker should look for the Dockerfile
in the current directory.
下一步,run一个contianer
tart your container using the docker run
command and specify the name of the image we just created:
docker run -dp 3000:3000 getting-started
Remember the -d
and -p
flags? We're running the new container in "detached" mode (in the background) and creating a mapping between the host's port 3000 to the container's port 3000. Without the port mapping, we wouldn't be able to access the application.
After a few seconds, open your web browser to http://localhost:3000
这个时候,默认run的是dockerfile,CMD那一行的命令。