docker || wordpress

wordpress可以快速构建一个自己的网站。

第1步:新建一个目录。

[root@docker Dockerfile]# mkdir wordpress

[root@docker Dockerfile]# cd wordpress/

[root@docker wordpress]#

第2步:vim docker-compose.yml。

[root@docker wordpress]# vim docker-compose.yml

[root@docker wordpress]# cat docker-compose.yml

services:

db:

# We use a mariadb image which supports both amd64 & arm64 architecture

image: mariadb:10.6.4-focal

# If you really want to use MySQL, uncomment the following line

#image: mysql:8.0.27

command: '–default-authentication-plugin=mysql_native_password'

volumes:

– db_data:/var/lib/mysql

restart: always

environment:

– MYSQL_ROOT_PASSWORD=somewordpress

– MYSQL_DATABASE=wordpress

– MYSQL_USER=wordpress

– MYSQL_PASSWORD=wordpress

expose:

– 3306

– 33060

wordpress:

image: wordpress:latest

volumes:

– wp_data:/var/www/html

ports:

– 80:80

restart: always

environment:

– WORDPRESS_DB_HOST=db

– WORDPRESS_DB_USER=wordpress

– WORDPRESS_DB_PASSWORD=wordpress

– WORDPRESS_DB_NAME=wordpress

volumes:

db_data:

wp_data:

[root@docker wordpress]# ls

docker-compose.yml

第3步:启动wordpress和数据库容器。

[root@docker wordpress]# docker compose up

[+] Running 2/0

⠿ Container wordpress-db-1 Running 0.0s

⠿ Container wordpress-wordpress-1 Running 0.0s

Attaching to wordpress-db-1, wordpress-wordpress-1

[root@docker wordpress]# docker compose ps

NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS

wordpress-db-1 mariadb:10.6.4-focal "docker-entrypoint.s…" db 7 hours ago Up 6 hours 3306/tcp, 33060/tcp

wordpress-wordpress-1 wordpress:latest "docker-entrypoint.s…" wordpress 7 hours ago Up 6 hours 0.0.0.0:80->80/tcp, :::80->80/tcp

第4步:浏览器里直接输入ip。

至此,你的一个网站就搭建好了。

原文链接:https://blog.csdn.net/qq_60271706/article/details/129630177

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享