I learn docker (1)--using MySQL

Source: Internet
Author: User
Tags docker run

Download image

Using the docker pull mysql:5.7.21 pull MySQL image, use docker images the view-owned image after the download is successful:


?
Downloaded MySQL image.

Create a new folder for persistence

1. Create a new folder $DEV_HOME/docker/mysql .
2, give it permission chmod 777 $DEV_HOME/docker/mysql , it seems that if you do not give it permission, Docker can not save the data inside.


?

The database file is then written directly to the local

Create a container

Use the command: docker run --name mysql -p 3306:3306 -v $DEV_HOME/docker/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123 -d mysql:5.7.21 create a container called "mysql".

    • -p 3306:3306: Maps local 3306 to port 3306 of the container.
    • -v $DEV_HOME/docker/mysql:/var/lib/mysql: Maps the local directory to the container directory.
    • -e MYSQL_ROOT_PASSWORD=123: The password of the root user of MySQL.

I learn docker (1)--using MySQL

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.