03 docker actual combat MySQL

1. Use the docker search command to search for mysql mirrors in public warehouses

STARS is the star rating of the mirror. The more stars, the more popular (it should be easy to understand if you are used to github).

OFFICIAL indicates whether it is an official mirror created and maintained.

2. Find the mysql version mirror

My local mysql version is 8.0.19. I hope that the server’s mysql is the same as the local one, so as to reduce the compatibility risk in later development and production deployment, so I went to the docker official website to find the corresponding version

The official warehouse address of docker: https://hub.docker.com/

After entering the official warehouse website, search for "mysql", as shown below:

The search results are as follows, click to enter the mysql mirror page:

After entering, click on the "Tags" option, you will see various versions of mysql appear below, latest means the latest version

Found version 8.0.19

3. At this time, direct download will be very slow, so first use Ali's container image to change the source

  •  Ali’s container mirroring service address: https://cr.console.aliyun.com  . Note that you must log in to enter.
  • After entering, click on the mirror accelerator, as shown in the figure below, and refer to the operation document configuration. I use vim to edit.

  • There is no daemon.json in my docker folder, so while editing with vim, create the file

  • Run the last two commands in the document, reload the configuration file, and restart docker. (You're done, the speed is guaranteed to fly^-^)

4. Use the docker pull command to download the docker image of mysql

docker pull mysql:8.0.19

5. Use the docker images command to view the local image

6. Use the docker run command to create and run the container, which is equivalent to docker create first and then docker start

docker run -itd --name mysql8019 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.19

7. Use the docker ps command to view the currently running container

8. Use Navicat to connect to the database, yeah!


Digression:

    1. docker rmi command can delete the image, followed by the label or ID number of the image;

    2. The running image of a container cannot be deleted. You can use the docker stop command to stop the container running, then use the docker rm command to delete the container, and finally delete the image;

    3.docker run -itd, the function of parameter d is to allow the container to run in the background

Guess you like

Origin blog.csdn.net/sunlylqq/article/details/112283607