I have a docker-compose-test.yml like so:
services:
environment-service:
image: ubuntu:24.04
command: "echo 'you should see string as the next string: $DRYRUNG'"
I run it like so:
docker-compose --file docker-compose-test.yml run -e DRYRUNG=string environment-service
with the following output:
WARNING: The DRYRUNG variable is not set. Defaulting to a blank string.
Pulling environment-service (ubuntu:24.04)...
24.04: Pulling from library/ubuntu
5a7813e071bf: Already exists
Digest: sha256:72297848456d5d37d1262630108ab308d3e9ec7ed1c3286a32fe09856619a782
Status: Downloaded newer image for ubuntu:24.04
Creating mbonnet_environment-service_run ... done
you should see string as the next string:
A second attempt, post-image-pull, gives
WARNING: The DRYRUNG variable is not set. Defaulting to a blank string.
Creating mbonnet_environment-service_run ... done
you should see string as the next string:
I expected output like:
Creating mbonnet_environment-service_run ... done
you should see string as the next string: string
Relevant system information:
$ docker-compose --version
docker-compose version 1.29.2, build unknown
$ docker -v
Docker version 28.0.0, build f9ced58
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble
To be clear, I do not wish to set wider environment variables in the shell I am using, nor do I wish to set them via an environment file like .env. I want to be able to do arbitrary values when I execute the docker-compose command.
These are also not secrets/credentials - the wider use is passing them as arguments to a command line tool, within Docker.