I’m currently trying to move my existing mariadb 10.0 installation into a docker container. I tried the following:
mkdir -p /data/mariadb
cp -r /var/lib/mysql/* /data/mariadb/
chown -R 503:503 /data/mariadb/*
docker run --name mariadb -v /data/mariadb:/var/lib/mysql -d mariadb:10.0
It starts succesfully and docker logs shows
mydqld: ready for connection
and I thought this should be all. All data from my existing db should be used, the mysql port should be exposed and it should just work with my webserver. But it doesn’t. I can’t connect to my database.
I’m new to docker, so I don’t really know where to start troubleshooting or if I did this totally wrong.
I would create new mariadb container with persistent volume and import it, because your exiting mariadb might be configured differently need to verify if both dockerized and exiting mariadb configured same.
to get the mysql docker instance
docker exec -it docker_id /bin/bash
which will put you in the mariadb bash you can take look it working or not
You didn’t give a -p
option, so no ports will be published and the database will be unreachable. There’s some very detailed documentation on it in the Docker docs.