Hi,
I’ve tried to use docker secrets as follows:
docker-compose.yml
version: "2"
services:
#mariadb
my-db-service:
image: wodby/mariadb:10.6
restart: always
container_name: my-db-service:
secrets:
- db_user
- db_password
environment:
- MYSQL_USER=/run/secrets/db_user
- MYSQL_PASSWORD=/run/secrets/db_password
- MYSQL_DATABASE=mydatabase
- MYSQL_ALLOW_EMPTY_PASSWORD=true
volumes:
- ./dbdata:/var/lib/mysql
- ./conf/mycustom.cnf:/etc/mysql/conf.d/custom.cnf
expose:
- "3306"
networks:
- my_network
secrets:
db_user:
file: ./my_db_user.txt
db_password:
file: ./my_db_pass.txt
Also, I’ve created the two text files containing the db_user and the db_pass.
When I run docker-compose and enter the my-db-service bash
then I can access the db_user and db_pass i.e.
cat /run/secrets/db_password
<MYSECRETPASSWORD>
But, when I try to login into the database I always get an “access denied”:
/var/lib/mysql$ mysql -u dbuser -p
Enter password:
ERROR 1045 (28000): Access denied for user 'dbuser'@'localhost' (using password: YES)
Any idea, whats going wrong here?
Maybe, docker secrets are restricted to docker-compose version 3 (since external secrets are)?
TIA!
Alex