I'm having a problem trying to use docker secrets on a remote host that I created with docker-machine.
Below is my docker-compose.yml:
version: "3.5"
services:
mysql:
image: mysql:5.7
container_name: mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password
secrets:
- db_root_password
secrets:
db_root_password:
file: ./db_root_password.txt
This works well locally, I can run docker-compose up and access mysql container.
docker-compose up
The root password has well be applied.
I'm now trying to run the container on the remote host that I created using docker-machine.
I first created the machine using docker-machine create (in this case, on exoscale cloud)
docker-machine create --driver exoscale ... MyMachine
Then I tried to deploy the host using:
eval $(docker-machine env MyMachine)
docker-compose up
However, when I try to run on the remote host, I got the following error:
ERROR: for mysql Cannot create container for service mysql: invalid mount config for type "bind": bind source path does not exist: /Users/user/path/to/db_root_password.txt
So it's still trying to load the secret with the path of the local file on my local machine. How can I use this secret on the remote host?
Thanks in advance for your help
It's looks like tour docker-machine can't find ./db_root_password.txt
Can you try to create the file db_root_password.txt
inside the docker-machine in the same path?