Pass in custom --build-args from .env* to a Dockerfile at buildtime
See original GitHub issueI 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:
- Created 4 years ago
- Comments:17 (17 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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
isSo perhaps it is a lagoon issue that we don’t expose
.env
as build-args.