Public Repository

Last pushed: 2 years ago
Short Description
Base image for mysql container.
Full Description

##Very Light-weight mysql Container

Minimalistic container used as a base for a MySQL server. For use as a stand-alone with other containers. Runs on Alpine Linux, and at less than 20 mb, makes for an ideal db companion to a LAMP server container.

Comes with default database named "mysite," with all privileges granted to user "root" with no password required (you will probably want to change these defaults).

###Example Usage:

Fire up a mysql container and map an available port to 3306.


docker run -it --name database -p 49158:3306 -d kricker/mysql-base:latest

Now fire up a web server and link it to the mysql container we just started (for this example, I'll use a drupal application) and again map it to an available port on my host machine :


docker run -it --name drupalserver --link database:mysql -p 8080:80 kricker/drupal-base:latest

####Accessing the Database

With the port mapping of 49158:3306 as outlined above ... the database can be accessed via command line, or using the mysql gui tool of your choice (I like sequel pro personally). Just use "localhost" as the host, and whatever port we've assigned to 3306 (in the example above we used 49158).


host: 127.0.0.1
user: root
password:
database: mysite
port: 49158

By default, there is a database set up named "mysite," with default user "root" and no password. WARNING: Probably not a good idea to keep that around if used on a live server. To disable this for a live environment, you'll want to delete the "mysite" db, and/or modify the mysql file located under:

###/root/initfile.sql


# /root/initfile.mysql contents. Creates a "mysite" db with all privileges granted to user root from any ip

CREATE DATABASE mysite;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

Enjoy.

Docker Pull Command
Owner
kricker

Comments (2)
kricker
2 years ago

Hey Geshan. Thanks for the comment. I went ahead and added some documentation on how to use. When I get more time, I'll change this to an auto-deploy so dockerfile and other contents can be made public.

In a nutshell, it's a very simple deal that just starts with Alpin linux, installs mysql, and then runs a script that makes mysql auto-start.

FROM alpine:3.1

EXPOSE 3306

RUN apk –update add bash mysql-client mysql && \

mkdir -p /var/lib/mysql && \

mkdir -p /etc/mysql/conf.d

start mysql

ENTRYPOINT /usr/bin/mysql_install_db –user=mysql –ldata=/sql && \

rc-update add mysql default && mysqld –skip-grant-tables –user=root –datadir='/sql';

geshan
2 years ago

Can you please add some documentation on how to use it and also open up the dockerfile, thanks.