question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass in custom --build-args from .env* to a Dockerfile at buildtime

See original GitHub issue

I have tried to use this pattern in lagoon, to allow a dockerfile to build from a specific image version.

ARG SOME_VERSION
FROM ourspace/nginx:${SOME_VERSION}

This works with docker-compose. The value is originally set in .env and passed in dynamically through docker-compose.yml, because it’s used multiple times). However in the lagoon build context there seems to be no way to set this as a --build-arg.

I think this is a feature request, but workaround suggestions are most welcome.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
bomokocommented, Nov 30, 2022

I’m going to close this ticket for now, since we have workarounds for build vars and we have issue 1130 which, I think, covers the use case here. Happy to reopen if not.

1reaction
rocketeerbkwcommented, Aug 8, 2019

Well according to this article only docker-compose uses .env files natively. Docker doesn’t read them at all, but lagoon does and exposes them during the build process.

Having said that, the official docs do have an example like your code so maybe that’s not the problem.

The reason I thought it might be syntax error is cause the docs say the error for an unset ARG is

[Warning] One or more build-args [foo] were not consumed.

So perhaps it is a lagoon issue that we don’t expose .env as build-args.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass Docker Environment Variables During The Image Build
Let's look at all the ways you can pass variables while building a Docker image, ... image build, you will need either ENV...
Read more >
How To Pass Environment Info During Docker Builds
ARG instruction defines a variable that can be passed at build time. Once it is defined in the Dockerfile you can pass with...
Read more >
Docker Build Arguments and Environment Variables
Build arguments works on the BUILD phase, it has no impact on the RUN phase of docker whereas the ENV can be used...
Read more >
How to use Docker Build Args and Environment Variables
Set the environment variable DOCKER_BUILDKIT=1 · Add below to the top of your dockerfile. This will ensure the docker build will use the...
Read more >
A way to pass build-time arguments from .env file to Docker
You didn't give your full error, so here just give you a workable solution, FYI: docker-compose.yaml:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found