Start a mysql server instance Starting a MySQL instance is simple:
$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag ... 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 and tag is the tag specifying the MySQL version you want. See the list above for relevant tags.
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 mysql 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 Example stack.yml for mysql:
version: '3.1'
services:
db: image: mysql command: --default-authentication-plugin=mysql_native_password restart: always environment: MYSQL_ROOT_PASSWORD: example
adminer: image: adminer restart: always ports: - 8080:8080
Run docker stack deploy -c stack.yml mysql (or docker-compose -f stack.yml up), wait for it to initialize completely, and visit http://swarm-ip:8080, http://localhost:8080, or http://host-ip:8080 (as appropriate).
Content type
Image
Digest
Size
131.3 MB
Last updated
about 8 years ago
docker pull crisjk93/mysql