Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Unable to pass an environment variable to the Dockerfile build process #1529

Answered by charleskorn
gavinharriss asked this question in Q&A
Discussion options

You must be logged in to vote

If you'd like to pass an environment variable to the Dockerfile build process, there are a couple of things you need to do:

  1. Pass the environment variable as a build arg to the Dockerfile in your Batect config, for example:

    containers:
      aspnet:
        build_directory: . 
        build_args:
           secret_key: $secret_key # Note that the <{...} syntax is for config variables, not environment variables
  2. Declare the build arg in your Dockerfile with ARG and then either create an environment variable with the value of the build arg, or use the value directly in subsequent commands:

    ARG secret_key
    ENV secret_key=$secret_key # or eg. RUN do-secret-stuff --key=$secret_key

There's more detailed inf…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@gavinharriss
Comment options

Answer selected by gavinharriss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants