Docker creates an mysql container and saves it as a local mirror
- 2020-06-15 10:30:31
- OfStack
Find the mirror image on docker hub
[root@wls12c ~]$ docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relati... 2903 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Crea... 190 [OK]
centurylink/mysql Image containing mysql. Optimized to be li... 46 [OK]
Download the image locally
[root@wls12c ~]$ docker pull mysql
The default download is officially maintained by docker, which is the first to arrive from search.
Create a container
[root@wls12c ~]$ docker run --name mysqldb -e MYSQL_ROOT_PASSWORD=root -d mysql
-ES18en, specifying the environment variable.
Get IP mirror image of mysql
[root@wls12c ~]$ docker inspect mysqldb|grep IPAddress
"IPAddress": "172.17.0.4",
"SecondaryIPAddresses": null
Connection mysql
[root@wls12c ~]$ mysql -h 172.17.0.4 -u root -p
The password is root as specified above
Save the initialized mysql as a mirror
[root@wls12c ~]$ docker commit mysqldb mysql:1.0
3ed4a367c21eb509f1c4e0a772c3e5bdff678497be55700ea256ef34ad87cfc6
[root@wls12c ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
mysql 1.0 3ed4a367c21e 3 seconds ago 384.6 MB
mysql latest 826df4733292 37 hours ago 384.5 MB
centos latest d83a55af4e75 3 weeks ago 196.7 MB
cirros latest d8ca8144dee3 7 months ago 7.735 MB