I've been able to access Mysql console on a Mariadb Docker container.
From my local machine I can run this command to access the console (I have mariadb installed locally):
mysql -h localhost -P 3306 -u lc -p --protocol tcp
The issue rise when I try to use Docker secrets instead of explicitly writing password on the docker-compose.yml
file.
Working configuration
So, with this I can access mysql console:
services:
mariadb:
image: mariadb
environment:
MYSQL_DATABASE: my_db
MYSQL_ROOT_PASSWORD: 'pw'
volumes:
- db_data:/var/lib/mysql
ports:
- '3306:3306'
Issue
As soon as I move the secrets to a file, I cannot access anymore.
services:
mariadb:
image: mariadb
environment:
MYSQL_DATABASE: my_db
MYSQL_ROOT_PASSWORD: ./env/mysql_root_password.tx
volumes:
- db_data:/var/lib/mysql
ports:
- '3306:3306'
secrets:
mysql_root_password:
file: ./env/mysql_root_password.txt
The secrets work because the Wordpress container access it easily, so possibly the password pw
is turned into something else when retrieved from a secret.
Any idea?