0

I'm trying to use args in Dockerfile CMD. I know that we should use ENV in CMD so I've tried to do this but nothing happened in my case.

kvs is a bynary file built from Golang application.

My Dockerfile:

FROM alpine

ARG HOST
ENV HOST_NAME=$HOST

COPY kvs /
COPY *.crt /
COPY *.key /

EXPOSE 8080
CMD ["/kvs", "-host", $HOST_NAME]

I've tryied:

CMD ["/kvs", "-host", ${HOST_NAME}]

CMD ["/kvs", "-host", $HOST_NAME]

CMD ["/kvs", "-host", "${HOST_NAME}"]

CMD ["/kvs", "-host", "$HOST_NAME"]

CMD ["/kvs", "-host", "echo $HOST_NAME"]

CMD ["/kvs", "-host", "echo ${HOST_NAME}"]

Nothing from above is working!

Error is:

/bin/sh: [/kvs,: not found

Any ideas?

Morani
  • 446
  • 5
  • 15

1 Answers1

0

The answer is:

CMD /kvs -host=$HOST_NAME

Any other ways is not working. I hope that it will help someone.

This is not working:

CMD ["/kvs", "-host=$HOST_NAME"]
Morani
  • 446
  • 5
  • 15