Import data into MySql with docker-compose

Having a docker-compose setup which involves a Database like Mysql or MariaDB, then at some point you might want to import data into those Databases.

There are several ways to import the data in your docker-compose setup.

  1. Using a volume for import data
  2. Using mysql client from commandline with docker-compose exec
  3. Using phpmyadmin in docker-compose setup
  4. Using a mysql GUI client on the host and connect to the DB in the Docker container

So let’s see how we can do this:

Continue reading “Import data into MySql with docker-compose”

Recreate pruned docker networks with docker-compose

So here is nice chain of docker errors and its solution.

1. Docker has reached its maximum of created networks and errors like this:

ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

The easiest (and most brute though) solution to this is to prune all networks, as suggested here on SO.

docker network prune

This will delete all networks that are not connected to currently active containers.
But this also means it will delete all networks of your not runnning dev projects.
(Which might be numerous as in my case.)

Continue reading “Recreate pruned docker networks with docker-compose”

Docker-compose and Unknown MySQL server host

In case you encounter this error with mysql and your docker-compose setup:

Unknown MySQL server host <mysql-service-name>Code language: HTML, XML (xml)

… and you dont know why because everything seems to be correct.

Then you might have an upgrade problem with mysql because you are reusing an old volume that was created for another mysql version.
This can happen when you use a unspecified tag as mysql:latest (not recommended anyway) and there was a version bump in the official mysql image.
Or you upgraded the mysql container yourself, f.e. from mysql:5.6 to mysql:5.7 and you are reusing the data volume with the mysql files.

Continue reading “Docker-compose and Unknown MySQL server host”

Adminer for Sqlite in Docker

Recently i wanted to use Sqlite with Adminer in Docker and it turned out to be not so easy.
I actually thought i could just declare Adminer in a docker-compose.yml file with a volume mounted, similar as i would do for adminer with mysql.

Update: Today i would rather use the IntelliJ Database Tool for Sqlite administration.

But since Adminer is a popular hacking target they introduced a feature that does not allow to run adminer without a password, out of the box.
Sqlite database usually runs without password and dang, workaround needed!

Continue reading “Adminer for Sqlite in Docker”