Setup MySQL Server on Docker

So now i come to setup a MySQL Server on my first Docker environement and like MS SQL Server i found a one liner i like to share:

docker run -d --name mysql01 --hostname mysql01 -e MYSQL_ROOT_PASSWORD=Pwd2023 -p 6603:3306 -v mysql-conf:/etc/mysql/conf.d -v mysql-data:/var/lib/mysql --network network01 mysql

I think its self explaind.

How to get Docker containers to communicate by name instead of ip-address`?

Docker adding all new containers default to a bridge network but on the default bridge network you only can communicate between containers with ip-address, to communicate with containers name instead you need to define your own bridge network:

docker network create --driver bridge network01 --subnet=10.11.0.0/16

Then when you run the container add –network network01 to let the container connect to the new network and you can then communicate between containers by using the name you set on the container instead of communicate by ip-address that changes after a reboot and other things.

Setup a MS SQL Server on Docker

I have started to learn Docker and a nice one liner to have saved somewhere is this one that setting up a docker container with MS SQL server and a SA password + setting up a docker volume to hold the data for MS SQL Server.

The one-line:

docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=<YourStrong@Passw0rd>' -p 1433:1433 -v sqlvolume:/var/opt/mssql --name sql1 --hostname sql1 -d mcr.microsoft.com/mssql/server:2019-latest

Reference information can be found on https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker