https://github.com/chen0040/dockerfile-centos-mariadb
Package provides the dockerfile which setup and run the mariadb on centos VM with configuration overwrite and database setup
https://github.com/chen0040/dockerfile-centos-mariadb
centos-vm docker-container docker-image mariadb
Last synced: about 2 months ago
JSON representation
Package provides the dockerfile which setup and run the mariadb on centos VM with configuration overwrite and database setup
- Host: GitHub
- URL: https://github.com/chen0040/dockerfile-centos-mariadb
- Owner: chen0040
- License: mit
- Created: 2017-05-04T03:34:28.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-04T04:07:28.000Z (about 9 years ago)
- Last Synced: 2025-04-03T13:48:00.348Z (about 1 year ago)
- Topics: centos-vm, docker-container, docker-image, mariadb
- Language: Shell
- Size: 83 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dockerfile for mariadb
Package provides the dockerfile which setup and run the mariadb on centos VM with configuration overwrite and database setup
 
# Features
* The docker image is built from centos/systemd
* Allow user to create a database in the mariadb if the database is not created when docker container is started
* Allow user to configure the password for the 'root' account of mariadb
* Allow user to user to ssh into the container to start or stop the mariadb if needed
* Allow user to configure the mariadb such as default encoding, maximum connections, max packat allowed
# Usage
Git clone the project to your local computer:
```bash
git clone https://github.com/chen0040/dockerfile-centos-mariadb.git
```
## Build the mariadb docker image
Run the following command from the root folder of the project to build your own docker image:
```bash
docker build -t xschen/mariadb .
```
You can optionally save the image by running the following command:
```bash
docker save -o xschen-mariadb.img xschen/mariadb
```
## Create and start the docker container
```bash
docker run -it --name=xschen-mariadb -u 0 -d -p 3306:3306 xschen/mariadb
```
Now you should be able to connect to the mariadb from your local computer at the port 3306,
an example of the data source url will be:
jdbc:mysql://127.0.0.1:3306/my_database?useSSL=false&useUnicode=yes&characterEncoding=UTF-8
Note that 127.0.0.1 may need to be replaced with the ip of your docker machine VM (depends how you set up your docker machine)
## Start and stop the mariadb in the container
To start or stop the mariadb in the container, make sure that the container is running, then run the following command from your local computer:
```bash
docker exec -it xschen-mariadb /bin/bash
```
Once in the container, run the following command to start or stop the mariadb:
```bash
$ cd /home/xschen
$ sudo ./start.sh
```
```bash
$ cd /home/xschen
$ sudo ./stop.sh
```