dongshipang8094 2018-09-20 16:48
浏览 160
已采纳

在Dockerfile中为Swagger生成的Go服务器传递参数

I'm new to writing Dockerfiles and using Swagger so I was wondering if someone could help me with one thing. I'm building a binary from Swagger generated server code and I need to pass in arguments specific to the go server when running it, but passing it into ENTRYPOINT or CMD gives me "unknown flag" error.

My Dockerfile looks like this:

FROM golang:1.10.1-alpine3.7 AS build

RUN apk add --no-cache git
RUN go get github.com/golang/dep/cmd/dep

WORKDIR /go/src/<path_to_workdir>
RUN dep ensure -vendor-only

WORKDIR /cmd/data-server
ENV SRC_DIR=/go/src/<path_to_src_dir>
ADD . $SRC_DIR
RUN cd $SRC_DIR; go build -o data; cp data /cmd/data-server
ENTRYPOINT ["./data", "--scheme http"]

Which fails, on the previously mentioned error. How can I do this correctly?

  • 写回答

1条回答 默认 最新

  • dsb238100 2018-09-20 18:23
    关注

    You can write

    ENTRYPOINT ["./data", "--scheme",  "http"]
    

    then you would simply need docker run name-of-image

    or you can pass the arguments when running the image

    docker run --scheme http
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Android STD快速启动
  • ¥15 如何使用simulink建立一个永磁同步直线电机模型?
  • ¥30 天体光谱图的的绘制并得到星表
  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动