先可以在dockerhub上查看Wordpress的详情:
Dockerhttps://hub.docker.com/search?q=wordpress
具体速度慢的问题如下:
现在打开docker右上角的设置图标,并进入docker engine,添加如下代码:
"registry-mirrors": [
"https://registry.docker-cn.com",
"https://mirror.ccs.tencentyun.com"
]
添加完之后的样子应该是:
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"registry-mirrors": [
"https://registry.docker-cn.com",
"https://mirror.ccs.tencentyun.com"
]
}
点击apply&restart。
桌面新建文件夹docker-wordpress,创建txt文件后重命名为docker-compose.yml,用vscode或者记事本打开,输入如下内容:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
volumes:
wordpress:
db:
运行powershell,转到文件夹docker-wordpress目录下,运行:
docker-compose up -d
如图:
查看docker中的images或者containers,Wordpress和MySQL已经安装并运行了。
在浏览器中输入:
localhost:8080
如下图,表明成功!