It suppose to treat it as a path. But it is thinking "/run/secrets/mypassword" is the actual password. "_FILE" is already used.
I have tried give '' to it. It is still not working
When I go to /run/secrets/mypassword, I can see secret file and inside the file is the correct password.
Below is my docker-compose.yml.Anyone can give some advice, please? Thank you very much
version: '3.1'
services:
mariadb:
image: 'mariadb:10.6'
working_dir: /application2
volumes:
- '.:/application2'
- db1:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD_FILE : /run/secrets/mypassword
MYSQL_DATABASE: db1
MYSQL_USER: user1
MYSQL_PASSWORD_FILE : /run/secrets/mypassword2
secrets:
- mypassword
- mypassword2
ports:
- '21003:3306'
networks:
- app2
secrets:
mypassword:
file: mypassword.txt
mypassword2:
file: mypassword2.txt
CodePudding user response:
Be aware that the environment variables are only used if no database exists when the container starts. You map a volume to /var/lib/mysql
, so chances are that you already have a database and then it'll use the password defined in that.
Try and remove the volume mapping and see if it works.