官网地址
[root@VM-0-6-centos home]# mkdir my_wordpress
- 在目录下创建
docker-compose.yml
[root@VM-0-6-centos home]# cd my_wordpress
[root@VM-0-6-centos my_wordpress]# vi docker-compose.yml
version: "3.9"
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- wordpress_data:/var/www/html
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
wordpress_data: {}
- 启动项目
docker-compose up -d
, -d
为后台启动
[root@VM-0-6-centos my_wordpress]# docker-compose up -d
Creating network "my_wordpress_default" with the default driver
Creating volume "my_wordpress_db_data" with default driver
Creating volume "my_wordpress_wordpress_data" with default driver
Pulling db (mysql:5.7)...
5.7: Pulling from library/mysql
b4d181a07f80: Pull complete
a462b60610f5: Pull complete
578fafb77ab8: Pull complete
524046006037: Pull complete
d0cbe54c8855: Pull complete
aa18e05cc46d: Pull complete
32ca814c833f: Pull complete
52645b4af634: Pull complete
bca6a5b14385: Pull complete
309f36297c75: Pull complete
7d75cacde0f8: Pull complete
Digest: sha256:1a2f9cd257e75cc80e9118b303d1648366bc2049101449bf2c8d82b022ea86b7
Status: Downloaded newer image for mysql:5.7
Pulling wordpress (wordpress:latest)...
latest: Pulling from library/wordpress
b4d181a07f80: Already exists
78b85dd8f014: Pull complete
8589b26a90be: Pull complete
f5af5d641946: Pull complete
614ec6f0b8d6: Pull complete
12b28f3797fb: Pull complete
96bcb7d2e6b0: Pull complete
09a46dfaa772: Pull complete
1a85b508a14e: Pull complete
c6fd9c89235a: Pull complete
40b955b2d455: Pull complete
fda03b9af7e2: Pull complete
570ea029c915: Pull complete
a3f5858f9e8b: Pull complete
e563e5b2630b: Pull complete
10499c79181c: Pull complete
7180626436df: Pull complete
72df520dac82: Pull complete
ed2d407056b5: Pull complete
7224b35f0930: Pull complete
7bf10a169530: Pull complete
Digest: sha256:37be4c1afbce8025ebaca553b70d9ce5d7ce4861a351e4bea42c36ee966b27bb
Status: Downloaded newer image for wordpress:latest
Creating my_wordpress_db_1 ... done
Creating my_wordpress_wordpress_1 ... done
[root@VM-0-6-centos my_wordpress]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
679cc77ecfb6 wordpress:latest "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:8000->80/tcp, :::8000->80/tcp my_wordpress_wordpress_1
dd01a646ae90 mysql:5.7 "docker-entrypoint.s…" About a minute ago Up About a minute 3306/tcp, 33060/tcp my_wordpress_db_1
- 查看项目
http://IP:8000
本机查看http://localhost:8000
创建成功
网友评论