0

Dockerfile:

ARG arg
FROM main-registry.gitlab.com/base/folder/:{$arg}

specific conda environment file to use
ARG conda_environment=environment.yml

COPY . .

RUN conda update --quiet conda

I need to replace this $arg with the value provided in the build command:

docker build --build-arg arg="image_id" -t hello .

I am getting the arg correctly but I am not able to replace the value of the argument in url.

Ideal case:

new url = url/image_id

Reality:

new url = url/$arg

3
  • Can you please post an actual unedited snippet or all of your Dockerfile? Your syntax seems wrong with the {} from what you originally posted. Seems like it should be FROM url/${arg} instead Commented Mar 3, 2021 at 2:07
  • ARG arg FROM main-registry.gitlab.com/base/folder/:{$arg} # specific conda environment file to use ARG conda_environment=environment.yml COPY . . RUN conda update --quiet conda Commented Mar 3, 2021 at 2:17
  • can you please edit your post instead of posting this in a comment? Thanks! Commented Mar 3, 2021 at 2:18

1 Answer 1

1

I've done this before.

In your Dockerfile, you can have ARG commands before your initial FROM e.g. The following is taken from one of my Dockerfile templates (for ASP.NET Core multi-stage docker build):

ARG BUILD_IMAGE_TAG
ARG RUNTIME_IMAGE_TAG

FROM mcr.microsoft.com/dotnet/core/sdk:${BUILD_IMAGE_TAG} AS build

...

FROM mcr.microsoft.com/dotnet/core/aspnet:${RUNTIME_IMAGE_TAG} AS runtime

...

I suspect you've just got the syntax slightly wrong; {$arg} should be ${arg} as per my example above.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks it worked. I was missing the : and was giving /.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.