docker-compose up没有建立

I am trying to build and run a golang app with docker-compose. Here are my settings:

./docker/Dockerfile
./main.go
Makefile

Makefile

compose:
        env GOOS=linux GOARCH=amd64 GOARM=7 go build
        cd docker && docker-compose up

./docker/Dockerfile

FROM golang:1.11

COPY app .
CMD ["./app"]

./docker/docker-compose.yml

version: '3'
services:
    app:
        build:
            context: ../
            dockerfile: ./docker/Dockerfile
        env_file: ./app.env
        ports:
            - '9292:8000'

I run the following command, expecting to build a new binary and run it inside a Docker container.

$make compose

It runs great, but if I run the same command after updating main.go the new binary isn't copied to docker container. The docker container seems to use the previous binary (i.e. the first binary that was copied when the container was first constructed).

Can someone explain why this is happening and what should I do to fix it?

1个回答



关键是在 docker-compose up </ code>中使用-build </ code>选项 。
我希望每次 docker-compose up </ code>都能够重建,但是一旦容器从以前的构建和创建开始,它就启动。</ p>
</ div>

展开原文

原文

The key was to use --build option in docker-compose up. I expected docker-compose up to rebuild every time, but it just starts the container once it has been built and created from before.

duanniesui6391
duanniesui6391 我想您可以将此问题标记为已解决。 :)
11 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问