1,docker Pull MySQL image :
docker pull mysql:latest
2,docker View local image :
docker images
3, function MySQL container :
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456
mysql
4, View running containers
docker ps -a
5, close mysql
docker stop 20c9f0d80723 ( be careful : Here 20c9f0d80723 Yes, No 4 Found in step mysql of CONTAINER ID
, According to your container ID fill in )
6, function mysql container
docker run -dit --name mysql8.0 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456
mysql
7, get into mysql container
docker exec -it mysql8.0 /bin/bash
8, Sign in mysql
mysql -u root -p123456
Parameter description :
-p 3306:3306 : Mapping Container Services 3306 Port to host 3306 port , External hosts can directly Host computer ip:3306 Access to MySQL Services for .
MYSQL_ROOT_PASSWORD=123456: set up MySQL service root User's password .
4, You can view the started docker container
docker ps
Technology
Daily Recommendation