我的编程空间,编程开发者的网络收藏夹
学习永远不晚
位置:首页-资讯-开源

使用docker compose一键部署WordPress博客的方法

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

使用docker compose一键部署WordPress博客的方法

1、创建wordpress项目目录

[root@docker ~]# mkdir wordpress
[root@docker ~]# cd wordpress/
[root@docker wordpress]# 

2、创建docker-compose.yml配置文件

[root@docker wordpress]# touch docker-compose.yml
[root@docker wordpress]# vim docker-compose.yml 
[root@docker wordpress]# cat docker-compose.yml 
version: "3.3"
    
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
      - wordpress_data:/var/www/html
    ports:
      - "8000:80"
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
volumes:
  db_data: {}
  wordpress_data: {}
[root@docker wordpress]# 

3、一键启动wordpress项目

docker-compose up -d

命令运行执行过程如下所示

[root@docker wordpress]# docker-compose up -d
Creating network "wordpress_default" with the default driver
Creating volume "wordpress_db_data" with default driver
Creating volume "wordpress_wordpress_data" with default driver
Pulling wordpress (wordpress:latest)...
latest: Pulling from library/wordpress
a2abf6c4d29d: Pull complete
c5608244554d: Pull complete
2d07066487a0: Pull complete
1b6dfaf1958c: Pull complete
32c5e6a60073: Pull complete
90cf855b27cc: Pull complete
8b0f1068c586: Pull complete
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
Creating wordpress_db_1 ... done
Creating wordpress_wordpress_1 ... done

4、查看相关信息参数

查看正在运行的容器

[root@docker wordpress]# docker ps
CONTAINER ID   IMAGE              COMMAND                  CREATED              STATUS              PORTS                                   NAMES
74dde54efbe0   wordpress:latest   "docker-entrypoint.s…"   About a minute ago   Up About a minute   0.0.0.0:8000->80/tcp, :::8000->80/tcp   wordpress_wordpress_1
f22bc03ae9ca   mysql:5.7          "docker-entrypoint.s…"   About a minute ago   Up About a minute   3306/tcp, 33060/tcp                     wordpress_db_1
[root@docker wordpress]# 

查看wordpress镜像

[root@docker wordpress]# docker images
REPOSITORY        TAG                IMAGE ID       CREATED         SIZE
wordpress         latest             c3c92cc3dcb1   4 months ago    616MB
mysql             5.7                c20987f18b13   4 months ago    448MB

查看wordpress镜像详细信息参数

[root@docker wordpress]# docker image inspect wordpress
[
    {
        "Id": "sha256:c3c92cc3dcb1a903fed0374a837f38d716ae104d0e4c9705bddb53a76419534d",
        "RepoTags": [
            "wordpress:latest"
        ],
        "RepoDigests": [
            "wordpress@sha256:fc33b796b04162a0db2e9ea9b4c361a07058b21597b1317ad9ab3ea4593de241"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2021-12-22T12:22:44.907734362Z",
        "Container": "76e81f08668906b548f73ef1272100f6fa94ce50eb13bcb9701750958ccb9f7c",
        "ContainerConfig": {
            "Hostname": "76e81f086689",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "PHPIZE_DEPS=autoconf \t\tdpkg-dev \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkg-config \t\tre2c",
                "PHP_INI_DIR=/usr/local/etc/php",
                "APACHE_CONFDIR=/etc/apache2",
                "APACHE_ENVVARS=/etc/apache2/envvars",
                "PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
                "PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
                "PHP_LDFLAGS=-Wl,-O1 -pie",
                "GPG_KEYS=42670A7FE4D0441C8E4632349E4FDC074A4EF02D 5A52880781F755608BF815FC910DEB46F53EA312",
                "PHP_VERSION=7.4.27",
                "PHP_URL=https://www.php.net/distributions/php-7.4.27.tar.xz",
                "PHP_ASC_URL=https://www.php.net/distributions/php-7.4.27.tar.xz.asc",
                "PHP_SHA256=3f8b937310f155822752229c2c2feb8cc2621e25a728e7b94d0d74c128c43d0c"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"apache2-foreground\"]"
            ],
            "Image": "sha256:946e01a0332f0a94ab8098875adfccd45de7853714478cdc675c160bc190fa95",
            "Volumes": {
                "/var/www/html": {}
            },
            "WorkingDir": "/var/www/html",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {},
            "StopSignal": "SIGWINCH"
        },
        "DockerVersion": "20.10.7",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "PHPIZE_DEPS=autoconf \t\tdpkg-dev \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkg-config \t\tre2c",
                "PHP_INI_DIR=/usr/local/etc/php",
                "APACHE_CONFDIR=/etc/apache2",
                "APACHE_ENVVARS=/etc/apache2/envvars",
                "PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
                "PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
                "PHP_LDFLAGS=-Wl,-O1 -pie",
                "GPG_KEYS=42670A7FE4D0441C8E4632349E4FDC074A4EF02D 5A52880781F755608BF815FC910DEB46F53EA312",
                "PHP_VERSION=7.4.27",
                "PHP_URL=https://www.php.net/distributions/php-7.4.27.tar.xz",
                "PHP_ASC_URL=https://www.php.net/distributions/php-7.4.27.tar.xz.asc",
                "PHP_SHA256=3f8b937310f155822752229c2c2feb8cc2621e25a728e7b94d0d74c128c43d0c"
            ],
            "Cmd": [
                "apache2-foreground"
            ],
            "Image": "sha256:946e01a0332f0a94ab8098875adfccd45de7853714478cdc675c160bc190fa95",
            "Volumes": {
                "/var/www/html": {}
            },
            "WorkingDir": "/var/www/html",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": null,
            "StopSignal": "SIGWINCH"
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 616019481,
        "VirtualSize": 616019481,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/10e7ab6038414fc88332b2eae4cfb14dda92edab7760b81e2dcbae95be47eaeb/diff:/var/lib/docker/overlay2/2884bfc529cfa8044e82537076f6b15f0cb003b549b952668e276039bdceef9a/diff:/var/lib/docker/overlay2/e8e3a23fdb1faa46be8380d0476acd576a49a97befb0a018c65db5addac6c3a3/diff:/var/lib/docker/overlay2/aa9b79869b43445fbdc6a31f3f6bd4d902bbff010a9a6e109856e9ceea4bf4ad/diff:/var/lib/docker/overlay2/c139cd93e615ec61b79e69c94f4319f797b485b76d48f00ce9faa77c195fc452/diff:/var/lib/docker/overlay2/136d4761234aca9c82ca233753f250a46169f5401e51518811614ded12ebefa4/diff:/var/lib/docker/overlay2/f78ed7733ca7b5d5ef0f02ac04f98eb8c1e22f37a93a9f0278b7f3108c6f3a48/diff:/var/lib/docker/overlay2/6cdeaa8faad2381a61ae21c133a6bdcdb61cf558cf6e89fc9e8db7c352301d1f/diff:/var/lib/docker/overlay2/0b4cea44728b2d74bf39fb69f9ccb6402e2117ebf4d54b8f2d14653d032ba12f/diff:/var/lib/docker/overlay2/d27e9fcb57f79408927a6e2910086bad36d88291a601e877f028513840399bc3/diff:/var/lib/docker/overlay2/2f2b18318c209c0184b5766670808285e0545c1e68a1658efb511636d1033f28/diff:/var/lib/docker/overlay2/ed9a87da9254ad473c92a820295874ab67d88c492647ff1bb78e160b05c7dcc7/diff:/var/lib/docker/overlay2/dd7b9486ac80666eefc319070f00aeb1f26f1df1dda5301f57ab4c24ba2771b3/diff:/var/lib/docker/overlay2/0450b509c683bec9e8bad207d87a7eb505d69f086961be46e0c8df868ab1144e/diff:/var/lib/docker/overlay2/d55a71f8bab352884cdce71228f76973a7734a3a0a8a3facba3f496059346ba4/diff:/var/lib/docker/overlay2/2fe09d1aa764b041a3f27dd4399390e14b3fb64b4464fd5b26afef2a3a56f4bf/diff:/var/lib/docker/overlay2/87ba02c078abca0b51ee759547e0313ed0dbe26581ce034742ba938bfea5bf88/diff:/var/lib/docker/overlay2/d7ff4ef14ccaae7407682309049ce6158f389e4bd205b68886ac758461733422/diff:/var/lib/docker/overlay2/2e2cb15add20c5ba711c5273f1fdddb7f1a54d488952a8816d5b470f583b07b7/diff:/var/lib/docker/overlay2/b806a2064e4e38e04f61fc73eddb216c2de6d65ff83772fe4eb05a63887b0b00/diff",
                "MergedDir": "/var/lib/docker/overlay2/ae8ebfb3d264d1e16727a7b1ae2e717969a8907c5749ad6523f399b909b3bb06/merged",
                "UpperDir": "/var/lib/docker/overlay2/ae8ebfb3d264d1e16727a7b1ae2e717969a8907c5749ad6523f399b909b3bb06/diff",
                "WorkDir": "/var/lib/docker/overlay2/ae8ebfb3d264d1e16727a7b1ae2e717969a8907c5749ad6523f399b909b3bb06/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:2edcec3590a4ec7f40cf0743c15d78fb39d8326bc029073b41ef9727da6c851f",
                "sha256:2a3138346faa8ee4b6576fcbb2c6fee83f0bbe068d9bba5e3319929fcd8c7ada",
                "sha256:0fdfbbf7aebd824633c30eeb27764703e6542240276c77be96a361a0317a1048",
                "sha256:ee0ca96d307e2b44287feb00422347eca7e232623cd296836bc4fa667a5afb66",
                "sha256:6e4300c6b758e4eb09040760786bb6f80a2e9292a99473e04b5437ba49f223a5",
                "sha256:5649286863133a7dc1abc7e4df13abfb2ba9d9873f8b279e74321a4e4317cfcd",
                "sha256:6c39776a30a0f2123685eb293379f7662f41947245a4bb436612d12ac500e84d",
                "sha256:23946094ff3f63e854aa094f023dcb277ffec1ab69d8799c0ac0105d1f611bc1",
                "sha256:b299cffd87cbd3caccb7cc2d1bddf236693585f041fe9fde441d9a82feb20ff8",
                "sha256:56543a169be6589b8408e4aaa230e529870dafedd5cf191ced84a9ba13cd60b4",
                "sha256:55d40777afe64bab763a7d744513ddb93a29b3f5802ca0575fe03c0a8ed67dc9",
                "sha256:7446d340e7f8da0e738b0a1a9fb6a1fe906e7e9d238447a44519e6d1e225d30f",
                "sha256:10dfb82106c4667a9e465437331fe459e6d50369832b38d0a88b862f1cfa71e7",
                "sha256:d390f2d56bd85a24191a667840c3836506f73d69522ab793dcb41965f269f9a9",
                "sha256:0d79fe9ffe74abce48ccf46c394e162115ec5a40cf57e993f8c7f3041e1205f4",
                "sha256:4793c0a2ad02c5fab0556045d0a182c69218d0a8e892f32047b0666e472b406b",
                "sha256:a4e2d002482e345abd2cb9e92f0d86fd5af455752be758bc9b3c80c55ecacbce",
                "sha256:f0287c40b0d61bcb53f04716fab390a45d96af7f9e7104bce13793edc4a516c7",
                "sha256:98b68a8435741330255aa4c24df32f82b356e44fe0089dc288e3d74ef6722ac5",
                "sha256:8f1b90d2be40e2da876dc34793e4938ea1591b2f54e396f931564ee07ad1d585",
                "sha256:c7ae1aefcc695d00e45dd1cd3517ac92893f07c0915261609d044636e6d2c86b"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

查看wordpress的网络信息

[root@docker wordpress]# docker network ls
NETWORK ID     NAME                       DRIVER    SCOPE
6da4ea82dc8f   bridge                     bridge    local
6122e04c63b8   composetest_default        bridge    local
2fff17891e10   host                       host      local
7aa928301028   mynet                      bridge    local
e09cdd0344b3   none                       null      local
6e65d674deba   redis                      bridge    local
366cc0a1f57b   wordpress_default          bridge    local
531566df42e7   xybdiy_workpress_default   bridge    local

查看wordpress容器的网络详细信息

[root@docker wordpress]# docker network inspect 366cc0a1f57b
[
    {
        "Name": "wordpress_default",
        "Id": "366cc0a1f57b7b23ddfb5e46e3f6a48040294e61fc66a4065a2bfe163b48681c",
        "Created": "2022-04-23T22:58:30.173133699+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.20.0.0/16",
                    "Gateway": "172.20.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "74dde54efbe05c5e7a5f57c174272d9ab68f333b358f517e0763eea9040c9a47": {
                "Name": "wordpress_wordpress_1",
                "EndpointID": "919b186d0fb0d56026300450432091abcde8ebb411b5ae1db400297aa6f2cc1c",
                "MacAddress": "02:42:ac:14:00:03",
                "IPv4Address": "172.20.0.3/16",
                "IPv6Address": ""
            },
            "f22bc03ae9ca55daa657a98a0e5f212b14bd3ca57c3244cd50e588d871b6b1f2": {
                "Name": "wordpress_db_1",
                "EndpointID": "01ba837f9dc58acd3fa90655c4cc5d0d1b639aaab10c1dc1aa1f81ca8f04a2c9",
                "MacAddress": "02:42:ac:14:00:02",
                "IPv4Address": "172.20.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "wordpress",
            "com.docker.compose.version": "1.25.0"
        }
    }
]
[root@docker wordpress]# 

5、配置wordpress

http://192.168.200.8:8000/wp-admin/install.php

1、选择语言版本信息。

image-20220423230554932

2、配置相关信息。设置站点名、用户名、密码等。

image-20220423230808870

3、安装完成。

image-20220423230753321

4、使用用户名和密码登录wordpress。

image-20220423230852170

5、登录完成,进入wordpress博客后台。

image-20220423230952911

6、查看wordpress初始化网页界面。

image-20220423231017265

至此,wordpress通过docker-compose一键安装部署完成。

到此这篇关于docker compose一键部署WordPress博客的文章就介绍到这了,更多相关docker compose一键部署WordPress博客内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

使用docker compose一键部署WordPress博客的方法

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

教你使用Docker Compose一键部署前后端分离项目

Compose是一个定义和管理多容器的工具,使用Python语言编写,下面这篇文章主要给大家介绍了关于如何使用Docker Compose一键部署前后端分离项目的相关资料,需要的朋友可以参考下
2023-01-09

使用shell脚本一键部署LNMP架构的方法

LNMP架构介绍LNMP:linux系统下Nginx+mysql+php这种网站服务器架构。Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器。Mysql是一个小型关系型数据库管理系统。PHP是
2022-06-04

Docker部署及使用压测神器sysbench的方法

sysbench是一个开源跨平台的多线程性能测试工具,这篇文章主要介绍了Docker部署及使用压测神器sysbench的相关知识,需要的朋友可以参考下
2022-11-13

使用Docker部署MySQL数据库的两种方法

目录引言第一部分:通过 docker CLI 命令部署 mysql1. 安装 Docker2. 拉取 MySQL 镜像3. 启动 MySQL 容器4. 验证 MySQL 运行状态5. 进入 MySQL 容器第二部分:通过 Docker Co
使用Docker部署MySQL数据库的两种方法
2024-10-17

Docker自发现注册服务基础etcd的部署及使用方法

这期内容当中小编将会给大家带来有关Docker自发现注册服务基础etcd的部署及使用方法,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。1. 背景自发现服务基础需要一个高可用键值存储系统, 很容易联想到re
2023-06-19

使用docker 部署mysql突然连接不上的问题及解决方法

WARNING: IPv4 forwarding is disabled. Networking will not work.大概意思就是说,网络不能用,也就意味着不能连网络,所以远程才连不上mysql。找到原因之后,就简单了,可以对症
2022-06-28

编程热搜

  • wordpress错位如何解决
    这篇文章主要介绍“wordpress错位如何解决”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“wordpress错位如何解决”文章能帮助大家解决问题。wordpress
    wordpress错位如何解决
  • 帝国cms调用栏目别名的修改步骤
    请留意下面的修改方法 修改后栏目别名使用 !--bname--] 调用 打开e/class/t_functions.php搜索定位到带模板的栏目导航标签修改1复制代码代码如下://替换变量$bclassname=$class_r[$clas
    帝国cms调用栏目别名的修改步骤
  • 动易Cms MAC验证视图失败的解决方法
    “/”应用程序中的服务器错误。 -------------------------------------------------------------------------------- 验证视图状态 MAC
    动易Cms  MAC验证视图失败的解决方法
  • DEDECMS如何支持中文水印
    DEDECMS如何支持中文水印?修改/include/inc_photograph.php,在165行处加这行代码:$w_text = iconv("GB2312","UTF-8",$w_text);OK,现在可以用中文做水印了,但默认的字体大小是5,中文字体
    DEDECMS如何支持中文水印
  • 快速了解Discuz!程序文件功能
    相信有不少人热衷于基于修改原有系统文件所做的插件,当然了解程序文件功能是最重要的,下面我把Discuz! X2.0主要的程序文件功能说一下。Tips:Q:针对说明的文件是?A:我只基于原版文件对upload目录中基本的程序文件(php,ht
    快速了解Discuz!程序文件功能
  • DedeCMS编辑器fck更换成eWebEditor编辑器具体步骤
    将eWebEditor编辑器插入DEDE后台的效果: 完全Word在线编辑的功能,让你从此摆脱发可编辑器卡得死,进入流畅干净编辑界面新时代。 下面是具体步骤: 首先,你要知道eWebEditor是一个什么工具。 eWebEditor是由国
    DedeCMS编辑器fck更换成eWebEditor编辑器具体步骤
  • 允许 WordPress 上传任意文件的方法
    此时如果上传一个不在预定义编程客栈的安全扩展名列表,如.lrc,会报kAtKhHRl错: F编程客栈ile type does not meet security guidelines. Try another. 解决此问题有两方法: 在
    允许 WordPress 上传任意文件的方法
  • dedecms 软件下载模块中添加下载方式为迅雷下载联盟代码
    修改 /plus/download.php 文件 www.cppcns.com查找
    dedecms 软件下载模块中添加下载方式为迅雷下载联盟代码
  • dedecms网站tag标签全部静态化的解决方法
    更改tags.php文件在根目录 找到$tag = FilterSearch(urldecode($tag)); 替换为:$tag = urldecode($tag); 更改文件arc.taglist.class.php文件文件所在的路径是
    dedecms网站tag标签全部静态化的解决方法
  • 帝国CMS远程保存图片的方法
    本文实例讲述了帝国cms远程保存图片的方法。分享给大家供大家参考。 具体实现方法如下:复制代码代码如下:
    帝国CMS远程保存图片的方法

目录