使用图像,跳过(配图)

我目前正在尝试与 mongodbnode express的这个教程 Https://medium.com/@sunnykay/docker-development-workflow-node-express-mongo-4bb3b1f7eb1e

第一部分在哪里构建 docker-compose.yml工作良好 它的工作完全罚款构建本地,所以我试图标记它,并推进到我的 dockerhub学习和尝试更多。

这是本教程后面的 yml文件中的内容

version: "2"
services:
web:
build: .
volumes:
- ./:/app
ports:
- "3000:3000"

当我使用 docker-compose builddocker-compose up时,这就像一个魔咒

所以我试图把它推到我的 dockerhub,我也标记为 node-test

然后将 yml文件更改为

version: "2"
services:
web:
image: "et4891/node-test"
volumes:
- ./:/app
ports:
- "3000:3000"

然后我删除了所有的图像,我以前有,以确保这也工作... 但当我运行 docker-compose build我看到这个消息 error: web uses an image, skipping,什么也没有发生。

我试着在谷歌上搜索这个错误,但是没有什么发现。

有人能帮帮我吗?

先谢谢你

102809 次浏览

I found out, I was being stupid.

I didn't need to run docker-compose build I can just directly run docker-compose up since then it'll pull the images down, the build is just to build locally

in my case below command worked:

docker-compose up --force-recreate

I hope this helps!

Clarification: This message (<service> uses an image, skipping) is NOT an error. It's informing the user that the service uses Image and it's therefore pre-built, So it's skipped by the build command.

In other words - You don't need build , you need to up the service.

Solution:

run sudo docker-compose up <your-service>

PS: In case you changed some configuration on your docker-compose use --force-recreate flag to apply the changes and creating it again.

sudo docker-compose up --force-recreate <your-service>

My problem was that I wanted to upgrade the image so I tried to use:

  • docker build --no-cache
  • docker-compose up --force-recreate
  • docker-compose up --build

None of which rebuild the image.

What is missing ( from this post ) is:

docker-compose stop
docker-compose rm -f # remove old images
docker-compose pull  # download new images
docker-compose up -d