docker run和docker pull有什么区别

时间:2019-05-16 18:17:32

标签: docker

我是Docker的新手。谁能帮助我了解两者之间的区别  docker run img_namedocker pull img_name

它们的作用相同吗?

1 个答案:

答案 0 :(得分:2)

docker pull从注册表中提取图像或存储库。

docker run在新容器中运行命令。

它们的作用不同,但是,如果您将docker run与尚未拉出的图像一起使用,则docker run将调用docker pull

$ docker rmi hello-world
Untagged: hello-world:latest
Untagged: hello-world@sha256:6f744a2005b12a704d2608d8070a494ad1145636eeb74a570c56b94d94ccdbfc
Deleted: sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e
Deleted: sha256:af0b15c8625bb1938f1d7b17081031f649fd14e6b233688eea3c5483994a66a3
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:6f744a2005b12a704d2608d8070a494ad1145636eeb74a570c56b94d94ccdbfc
Status: Downloaded newer image for hello-world:latest

[...]

有关更多信息,请参见docker help pulldocker help run