I've been trying to figure out how to connect to a mariadb container while using podman-compose and I keep getting an error.
Here's what I've done:
Software Versions
podman version = 3.3.1
podman-compose version = podman-compose-0.1.7-2.git20201120.el8.noarch`
docker-compose.yml
version: '3'
services:
db:
image: mariadb:latest
environment:
MARIADB_USER: user
MARIADB_PASSWORD: pass
MARIADB_DATABASE: testdb
MARIADB_ROOT_PASSWORD: rootpass
volumes:
- db_data:/var/lib/mysql
When I spin this container up using: podman-compose up -d
Then try to connect to this database using:
podman exec -it project_db_1 mariadb -uroot -prootpass
I get this error:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I get this error both as a regular user and as the root user.
Yet, when I run the same container with podman:
Podman Command
podman run -d \
--name mariadb \
-e MARIADB_USER=user \
-e MARIADB_PASSWORD=pass \
-e MARIADB_DATABASE=testdb \
-e MARIADB_ROOT_PASSWORD=rootpass \
mariadb:latest
Then try to connect to this database using:
podman exec -it mariadb mariadb -uroot -prootpass
I am able to successfully login.
Can anyone please explain to me what I'm doing wrong with podman-compose or why it's not allowing me to login with the credentials I've given?
OK, for anyone that want's to know what I did to fix this... Firstly, I uninstalled podman & podman-compose because there were just too many issues with it, so I installed docker & docker-compose.
Secondly, when I ran this script in docker-compose, I got an error that wasn't showing up in podman-compose.
Error: services.db.environment must be a mapping
After Googling that error, I found out that I needed to format the environment section like this:
version: '3'
services:
db:
image: mariadb:latest
environment:
- MARIADB_USER=user
- MARIADB_PASSWORD=pass
- MARIADB_DATABASE=testdb
- MARIADB_ROOT_PASSWORD=rootpass
volumes:
- db_data:/var/lib/mysql
After I fixed that, docker-compose ran beautifully and I could connect to my database, even from another container. I did do a test using podman-compose with this code fix, and it still wouldn't work. So I'm just going to use docker until podman fixes their issues.