feiti
feiti

Reputation: 87

Passing in arguments in a Dockerfile for a Swagger generated Go server

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?

Upvotes: 1

Views: 287

Answers (1)

edkeveked
edkeveked

Reputation: 18381

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

Upvotes: 1

Related Questions