mircealungu
mircealungu

Reputation: 6981

Output of command on host into in ARG in Dockerfile

I need the output of a command run on the host to be used further in a Dockerfile.

Something like this:

ARG version
version = `cat version.txt` <--- this has to be run on the host
RUN sed -i "s/VER*/$version/g" /file/in/container

Is it clear what I mean? :) How to do this?

Upvotes: 1

Views: 690

Answers (1)

Mostafa Hussein
Mostafa Hussein

Reputation: 11980

What about using this command:

docker build --build-arg version=$(cat version.txt) .

The Dockerfile (Update: I have removed ENV and used the value of ARG directly)

ARG version
RUN sed -i "s/VER*/${version}/g" /file/in/container

Upvotes: 2

Related Questions