Giter VIP home page Giter VIP logo

docker-frodenas-mysql's Introduction

MySQL Dockerfile

A Dockerfile that produces a Docker Image for MySQL.

MySQL version

The master branch currently hosts MySQL 5.6.

Different versions of MySQL are located at the github repo branches.

Usage

Build the image

To create the image frodenas/mysql, execute the following command on the docker-mysql folder:

$ docker build -t frodenas/mysql .

Run the image

To run the image and bind to host port 3306:

$ docker run -d --name mysql -p 3306:3306 frodenas/mysql

The first time you run your container, a new user admin with all privileges will be created with a random password. To get the password, check the logs of the container by running:

docker logs <CONTAINER_ID>

You will see an output like the following:

========================================================================
MySQL User: "admin"
MySQL Password: "mKHBsVb2i7OrY26K"
========================================================================

Credentials

If you want to preset credentials instead of a random generated ones, you can set the following environment variables:

  • MYSQL_USERNAME to set a specific username
  • MYSQL_PASSWORD to set a specific password

On this example we will preset our custom username and password:

$ docker run -d \
    --name mysql \
    -p 3306:3306 \
    -e MYSQL_USERNAME=myusername \
    -e MYSQL_PASSWORD=mypassword \
    frodenas/mysql

Databases

If you want to create a database at container's boot time, you can set the following environment variables:

  • MYSQL_DBNAME to create a database

On this example we will preset our custom username and password and we will create a database:

$ docker run -d \
    --name mysql \
    -p 3306:3306 \
    -e MYSQL_USERNAME=myusername \
    -e MYSQL_PASSWORD=mypassword \
    -e MYSQL_DBNAME=mydb \
    frodenas/mysql

Persist database data

The MySQL server is configured to store data in the /data directory inside the container. You can map the container's /data volume to a volume on the host so the data becomes independent of the running container:

$ mkdir -p /tmp/mysql
$ docker run -d \
    --name mysql \
    -p 3306:3306 \
    -v /tmp/mysql:/data \
    frodenas/mysql

Copyright

Copyright (c) 2014 Ferran Rodenas. See LICENSE for details.

docker-frodenas-mysql's People

Contributors

frodenas avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.