https://vsupalov.com/docker-arg-env-variable-guide/
# no default value would crash
#ENV hey
# ENV needs a default value
ENV foo /bar
# you can also write
ENV foo=/barhttps://vsupalov.com/docker-arg-env-variable-guide/
Docker image and build both specified
If you add
build: "."to a service that will build a Docker image out of theDockerfilethat exists in the directory when youbuildorupyour compose file.If you add
image: "postgres:10.3-alpine"to a service that will pull down that image from the Docker Hub when youpullorupyour compose file.But what happens if you define both a build and image property like this:
web: build: "." image: "nickjj/myimage:1.0"The world won’t explode, so that’s good.
When the image gets built, instead of using your
COMPOSE_PROJECT_NAMEor folder name + service name as the name of the image it will use what you have in theimageproperty.In the above example you would end up with an image named and tagged as
nickjj/myimage:1.0which will be built out of theDockerfilein the current directory.
https://nickjanetakis.com/blog/docker-tip-57-using-build-and-image-in-the-same-docker-compose-service
No comments:
Post a Comment