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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序