docker compose pull
描述 | 拉取服务镜像 |
---|---|
用法 | docker compose pull [OPTIONS] [SERVICE...] |
描述
拉取在 compose.yaml
文件中定义的服务关联的镜像,但不会基于这些镜像启动容器
选项
选项 | 默认值 | 描述 |
---|---|---|
--ignore-buildable | 忽略可构建的镜像 | |
--ignore-pull-failures | 拉取能拉取的镜像,并忽略拉取失败的镜像 | |
--include-deps | 也拉取声明为依赖的服务 | |
--policy | 应用拉取策略("missing"|"always") | |
-q, --quiet | 拉取时不打印进度信息 |
示例
请参考以下 compose.yaml
services:
db:
image: postgres
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/myapp
ports:
- "3000:3000"
depends_on:
- db
如果你在定义服务的 compose.yaml
文件所在目录中运行 docker compose pull ServiceName
,Docker 会拉取关联的镜像。例如,要拉取示例中配置为 db 服务的 postgres 镜像,你可以运行 docker compose pull db
。
$ docker compose pull db
[+] Running 1/15
⠸ db Pulling 12.4s
⠿ 45b42c59be33 Already exists 0.0s
⠹ 40adec129f1a Downloading 3.374MB/4.178MB 9.3s
⠹ b4c431d00c78 Download complete 9.3s
⠹ 2696974e2815 Download complete 9.3s
⠹ 564b77596399 Downloading 5.622MB/7.965MB 9.3s
⠹ 5044045cf6f2 Downloading 216.7kB/391.1kB 9.3s
⠹ d736e67e6ac3 Waiting 9.3s
⠹ 390c1c9a5ae4 Waiting 9.3s
⠹ c0e62f172284 Waiting 9.3s
⠹ ebcdc659c5bf Waiting 9.3s
⠹ 29be22cb3acc Waiting 9.3s
⠹ f63c47038e66 Waiting 9.3s
⠹ 77a0c198cde5 Waiting 9.3s
⠹ c8752d5b785c Waiting 9.3s
docker compose pull
会尝试拉取包含 build 部分的服务镜像。如果拉取失败,它会告诉你该服务镜像必须构建。你可以通过设置 --ignore-buildable
标志来跳过此步骤。