This is my docker-compose.yml file:
version: "3.9"
services:
db:
image: mariadb:10.5
restart: always
environment:
MARIADB_ROOT_PASSWORD: "mypassword"
MARIADB_DATABASE: "mydb"
MARIADB_USER: "myuser"
MARIADB_PASSWORD: "mypassword"
MYSQL_ROOT_PASSWORD: "mypassword"
MYSQL_DATABASE: "mydb"
MYSQL_USER: "myuser"
MYSQL_PASSWORD: "mypassword"
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 10s
retries: 10
This is how I build and start my container
docker-compose -f docker-compose.yml up --build -d
After MariaDB started I try to connect to the database inside the container
docker exec -it CONTAINERID /bin/bash
root@a88f9980d7f6:/# mariadb -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Any idea why this is not working for me?
System informations:
Docker version 20.10.17, build 100c701
Docker Compose version v2.6.1
Linux dev 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux
Debian GNU/Linux 10 (buster)
mariadb -u root -pmypassword
just to make sure you are not having a typo. This could put password in the terminal history (not secure)
Could also be an issue with the image.
docker-compose down
then you can do docker rmi mariadb:10.5
to remove the image and do docker-compose up -d
please note you dont need --build
as you are referencing an image in your docker-compose.yml
Alternatively you can do docker system prune
BUT THIS WILL REMOVE all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes. USE WITH CAUTION.