How can I pass a variable to the container I'm building?

I want to be able to pass a variable defined in the “variables” section of the Launch Development Environment to my application, so that the value can be used when I’m building my container.

1 Like

In order to pass a variable (or a secret) to your Dockerfile, you need to do it using the ARG Dockerfile instruction.

Then, pass your okteto variable/secret as an arg in the build section of your okteto manifest or your docker compose file.

It would look something like this:

build:
   context: .
   args:
      - MY_ARG=${MY_OKTETO_SECRET}
1 Like