dongyang4615 2019-02-23 23:00
浏览 252

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条回答 默认 最新

  • doufu4333 2019-02-23 23:50
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法