I have a docker-compose.yml
file, and in that a build context for a given service with a Dockerfile
.
Sample docker-compose:
version: '3'
services:
scd-service:
build:
context: ./cmd/some-service/
dockerfile: Dockerfile
args:
broker: redis:6379
queue: somequeue
depends_on:
- redis
networks:
- backend
redis:
image: "redis:alpine"
restart: unless-stopped
networks:
- backend
It can find the Dockerfile
and build it with: docker-compose up --build some-service
However, this will fail. The broker
and queue
args are never passed to the given Dockerfile.
Sample Dockerfile
:
FROM golang:1.11
// stuff...
ARG broker
ARG queue
CMD ["go", "run", "/go/src/github.com/org/project/cmd/some-service/some-service.go", "--broker $broker", "--queue $queue"]
As evident in the build stage, these are never parsed:
Step 7/7 : CMD ["go", "run", "/go/src/github.com/org/project/cmd/some-service/some-service.go", "--broker $broker", "--queue $queue"]
Whereafter the Go program crashes as the command line parameters are invalid.
How does one parse args from docker-compose
to a Dockerfile
?
Edit: Weirdly, I can echo the correct value?
Example:
ARG broker
ARG queue
RUN echo ${broker}
Outputs:
Step 7/8 : RUN echo ${broker}
---> Running in c84828847d9a
redis:6379
How is this not parsed onto the CMD?