WordPress
1.安装docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2.查看版本
[root@localhost ~]# docker-compose --version
-bash: /usr/local/bin/docker-compose: 权限不够
[root@localhost ~]# chmod +x /usr/local/bin/docker-compose
[root@localhost ~]# docker-compose --version
docker-compose version 1.29.2, build 5becea4c
3.创建文件compose
[root@localhost ~]# mkdir compose
[root@localhost ~]# cd compose
4.编辑docker-compose.yml
[root@localhost compose]# vim docker-compose.yml
version: '3.8'
services:
wordpress:
image: wordpress
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_PASSWORD: root12345
WORDPRESS_DB_USER: root
WORDPRESS_DB_NAME: wordpress
networks:
- my-bridge
volumes:
- wordpress-data:/var/www/html
mysql:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root12345
MYSQL_DATABASE: wordpress
volumes:
- mysql-data:/var/lib/mysql
networks:
- my-bridge
volumes:
mysql-data:
wordpress-data:
networks:
my-bridge:
driver: bridge
5.执行脚本
[root@localhost compose]# docker-compose up -d
Creating network "compose_my-bridge" with driver "bridge"
Creating volume "compose_mysql-data" with default driver
Creating volume "compose_wordpress-data" with default driver
Pulling wordpress (wordpress:)...
latest: Pulling from library/wordpress
a2abf6c4d29d: Already exists
c5608244554d: Already exists
2d07066487a0: Already exists
1b6dfaf1958c: Already exists
32c5e6a60073: Already exists
90cf855b27cc: Already exists
8b0f1068c586: Already exists
5355461305e8: Pull complete
ad1eec592342: Pull complete
e03fbc76cb78: Pull complete
1f5796e48b39: Pull complete
72fbe8e1d4e7: Pull complete
96edece66175: Pull complete
5f46f0743de2: Pull complete
c9f9671a5e1f: Pull complete
3f543dcd35b1: Pull complete
c88e21a0c2a0: Pull complete
964b4457a910: Pull complete
0d55fb9a64ef: Pull complete
fb009ff7c567: Pull complete
4f058a67a50d: Pull complete
Digest: sha256:fc33b796b04162a0db2e9ea9b4c361a07058b21597b1317ad9ab3ea4593de241
Status: Downloaded newer image for wordpress:latest
Pulling mysql (mysql:5.7)...
5.7: Pulling from library/mysql
72a69066d2fe: Pull complete
93619dbc5b36: Pull complete
99da31dd6142: Pull complete
626033c43d70: Pull complete
37d5d7efb64e: Pull complete
ac563158d721: Pull complete
d2ba16033dad: Pull complete
0ceb82207cd7: Pull complete
37f2405cae96: Pull complete
e2482e017e53: Pull complete
70deed891d42: Pull complete
Digest: sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94
Status: Downloaded newer image for mysql:5.7
Creating compose_mysql_1 ... done
Creating compose_wordpress_1 ... done
5.查看容器
[root@localhost compose]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
913fc734fb3e mysql:5.7 "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 3306/tcp, 33060/tcp compose_mysql_1
cf190d64b45a wordpress "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp compose_wordpress_1
6.登陆页面可以查看到
t.s…" 4 minutes ago Up 4 minutes 0.0.0.0:8080->80/tcp, :::8080->80/tcp compose_wordpress_1
**6.登陆页面可以查看到**
![1649387611249.png](https://img-blog.csdnimg.cn/img_convert/0c68a4e1a4c7d6a0a5e709f32dc3f19f.png)