Take the following simplified example:
services:
app:
image: alpine
env_file: config.env
entrypoint:
- /bin/sh
- -c
- 'echo "Var is: $$MY_VAR"'
I have config.env
locally with my local dev settings, and a config.env
on the server with production settings.
When I use docker-compose -H [email protected] up --build -d
, it uses my local config.env instead of the one on the server. I'd rather not store environment-specific configuration in my repository, however the methods recommended in the docker documentation all involve making separate .yml
files or .env
files on the same machine on which you're using docker-compose
.
So, my question is, how can I store configuration on my server, and use docker-compose
on my dev machine to deploy? Or am I better off just uploading the repo to the server and running docker-compose
there so I can use the remote env file?
I eventually went with creating my own deploy script that copies the docker-compose files to the server and using an environment file on the server: