How to use the official MySQL image of DockerHub, dockerhubmysql

Source: Internet
Author: User
Tags mysql command line docker hub

How to use the official MySQL image of DockerHub, dockerhubmysql

Preface

Recently, I have been trying to create a centos-based MySQL Image Based on the official centos image. However, after the image is created, the image size exceeds 1.5 GB, which is too bloated for common Docker images. The official mysql image provided by Docker Hub is 324 MB. At present, I have not found any good method to reduce the size of my image, so I should first use the official one!

Docker pull mysql: 5.7

How to use this Docker image?

1. Start a Mysql Server container (default port 3306)

docker run --name mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7

2. Start another container and access the Mysql server through a link

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

3. Start another container and access the Mysql server through the Mysql command line.

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

4. Go to the server console

docker exec -it mysql bash

5. View Mysql server logs

docker logs mysql

For more information, see https://hub.docker.com/_/mysql /.

Summary

The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.