Skip to content

Custom mysql docker images including custom configuration and persistent volume storage

Notifications You must be signed in to change notification settings

khalid-el-masnaoui/docker-mysql-exploring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MYSQL container custom image

Custom mysql image with presistent data storage

Exploring docker by creating custom mysql image with presistent data storage, and mapping the container user UID with the host UID to make shared files (via volumes) accessibles. The image will init a custom script (inside initScripts folder) to create a database,a table and insert some dummy data.

MYSQL Configurations ⚙️

The MYSQL image under this repository does not use default configs instead it relays on custom configurations. MYSQL is running under mysql user with UID mapped to the host local user's UID

Docker 🛠️

By default, the Docker will expose ports 3306/tcp for port mappings, so change this within the Dockerfile if necessary. When ready, simply use the Dockerfile to build the image.

Installation 🔌

Clone this repository and follow the simple steps:

# clone
$ git clone git@github.com:khalid-el-masnaoui/docker-mysql-exploring.git

#cd into the working diretcory
$ cd docker-mysql-exploring

#image build
$ docker build . -t cs-mysql -f Dockerfile --build-arg="UID=$(id -u)" --build-arg="GID=$(id -g)"

This will create the custom mysql image and pull-in/install the necessary dependencies and extensions.

Once done, run the Docker image and map the port to whatever you wish on your host. In this example, we simply map port 3306 of the host to port 3306 of the Docker (or whatever port was exposed in the Dockerfile):

#running the container container
$ docker run --rm  -p 3306:3306 --name mysql --mount type=volume,source=mysql-cs-data,destination=/var/lib/mysql --mount type=bind,source=./configurations,destination=/etc/mysql/conf.d --mount type=bind,source=./logs,destination=/var/log/mysql cs-mysql

#the bind mounts are for developement purposes

Verify the connection to the msql container server

docker exec -it mysql -u root -p
#if all went will - you will be propmpted to enter your password (specified in the Dockerfile)

About

Custom mysql docker images including custom configuration and persistent volume storage

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published