Sign inSign up

joyndjama/mysql

By joyndjama

Updated over 8 years ago

MySQL server with a predefine database call dbapp.

Image
1

249

joyndjama/mysql repository overview

How to use this image

DockerFile

Start a mysql server instance

Starting a MySQL instance is simple:

$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d joyndjama/mysql:latest

... where some-mysql is the name you want to assign to your container, my-secret-pw is the password to be set for the MySQL root user.

Connect to MySQL from an application in another Docker container

This image exposes the standard MySQL port (3306), so container linking makes the MySQL instance available to other application containers. Start your application container like this in order to link it to the MySQL container:

$ docker run --name some-app --link some-mysql:mysql -d application-that-uses-mysql

Connect to MySQL from the MySQL command line client

The following command starts another mysql container instance and runs the mysql command line client against your original mysql container, allowing you to execute SQL statements against your database instance:

$ docker run -it --link some-mysql:mysql --rm joyndjama/mysql:latest sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'

... where some-mysql is the name of your original mysql container.

This image can also be used as a client for non-Docker or remote MySQL instances:

$ docker run -it --rm mysql mysql -hsome.mysql.host -usome-mysql-user -p

More information about the MySQL command line client can be found in the MySQL documentation

... via docker stack deploy or docker-compose

Tag summary

Content type

Image

Digest

Size

137.7 MB

Last updated

over 8 years ago

docker pull joyndjama/mysql