I have a docker-compose.yml file which uses a few variables set in an .env file.
Is there an easy way to print the final version of the file, to check if everything was correctly replaced?
# .env
UBUNTU_VERSION=19.8
.
# docker-compose.yml
version: '3'
services:
myservice:
image: ubuntu:${UBUNTU_VERSION}
env-file:
- .env
Note:
Compose supports declaring default environment variables in an environment file named .env placed in the folder where the docker-compose
Documentation: https://docs.docker.com/compose/env-file/
Given the following files:
# docker-compose.yml
version: '3'
services:
myservice:
image: ubuntu:${UBUNTU_VERSION}
env-file:
- .env
# .env
UBUNTU_VERSION=20.01
You can run
docker-compose config
And you'll get the formatted config file out:
❯ docker-compose config
services:
myservice:
environment:
UBUNTU_VERSION: '19.8'
image: ubuntu:19.8
version: '3'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With