I’ve just discovered
--context and it’s wonderful. But there’s one option I’m missing; maybe it’s there and I just can’t find it; maybe I’m doing it wrong; otherwise it’s a feature request =).
How do I make
docker-compose --host run within a different project dir on the remote?
So to illustrate the problem I’ve created minimal project directory for this
example-app ├── config │ └── config.txt ├── docker-compose.yaml └── Dockerfile
The files have the following content:
version: '2.4' services: app: build: context: . volumes: - "./config:/config"
FROM busybox:latest ENTRYPOINT ["cat", "/config/config.txt"]
When I run this locally the
./config directory will be prefixed by my current directory and evaluate as let’s say
docker-compose up --build
This is all fine – “It works!”
I now want to deploy this to my remote server, aptly called
server in this example.
I’ll state the port number 22 explicitly.
First I copy the
config dir to the server in an
rsync -e "ssh -p 22" -Rav config user@server:exampleapp-remote/
The server now has this structure:
: home ├── user : └── exampleapp-remote └── config └── config.txt
Now I run
docker-compose locally, issuing it to deploy and invoke the app on the server using
docker-compose --host ssh://user@server:22 up --build
And it fails:
app_1 | cat: can't open '/config/config.txt': No such file or directory
--project-directory exampleapp-remote or
--project-directory /home/user/exampleapp-remote doesn’t work, as it accounts for the local directory (I guess).
config dir to the
/home/user/config doesn’t work either because the current dir prefix gets evaluated on the host running
What to do?
--remote-project-directory would be handy here.
Or maybe something like
--host ssh://user@server:22/~/exampleapp-remote or
Or if a
--context was used, perhaps a
remote-work-dir could be added to the
How do I solve this? How do I make
docker-compose --host run within a different project dir on the remote? Is it even doable?