1,查看MySQL镜像版本
[root@localhost ~]# docker search mysql
2,拉取MySQL5.7版本
[root@localhost ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
20e4dcae4c69: Pull complete
1c56c3d4ce74: Pull complete
e9f03a1c24ce: Pull complete
68c3898c2015: Pull complete
6b95a940e7b6: Pull complete
90986bb8de6e: Pull complete
ae71319cb779: Pull complete
ffc89e9dfd88: Pull complete
43d05e938198: Pull complete
064b2d298fba: Pull complete
df9a4d85569b: Pull complete
Digest: sha256:4bc6bc963e6d8443453676cae56536f4b8156d78bae03c0145cbe47c2aad73bb
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
3,创建MySQL容器 ,并端口映射
[root@localhost ~]# docker run -d --name=mysql01 -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 mysql:5.7
f0a23bdd72dee60f980d48a2dd42fd44b754d4ffb872734f1fb26308928999c3
4,进入MySQL中创建数据库(wordpress)
[root@localhost ~]# docker exec -it mysql01 /bin/bash
bash-4.2# mysql -u root -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.44 MySQL Community Server (GPL)
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
5,拉取个人博客镜像(wordpress)
[root@localhost ~]# docker pull wordpress
6, 创建wordpress容器并做端口映射
[root@localhost ~]# docker run -d --name=wordpress01 -p 80:80 wordpress
9b535d03d848a1c4c617764bb53d3797d77ccf67368d1de9db47caa113dd5843
7,在浏览器中打开wordpress
8, 安装wordpress