WordPress wp-config.php是否在Dockers中更新? [英] Wordpress wp-config.php doesn't update in Dockers?

查看:61
本文介绍了WordPress wp-config.php是否在Dockers中更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Wordpress和docker容器.问题是我更新了wp-config.php文件,但一切看起来都一样.我有这样的东西:

I am using Wordpress and docker container. The problem is that I updated the wp-config.php file but everything looks the same. I have something like this:

CONTAINER ID        IMAGE                   NAMES
b2711d4b72a1        phpmyadmin/phpmyadmin   website_phpmyadmin_1
8a89ee46d673        wordpress:4.7.5         website_wordpress_1
2a167667f705        mysql:5.7               website_db_1

我的docker-compose.yaml看起来像这样:

My docker-compose.yaml looks like this:

version: '2'
services:
wordpress:
depends_on:
  - db
image: wordpress:4.7.5
restart: always
volumes:
  - ./wp-content:/var/www/html/wp-content 
environment:
  WORDPRESS_DB_HOST: db:3306
  WORDPRESS_DB_PASSWORD: p4ssw0rd!
ports:
  - 80:80
  - 443:443
networks:
  - back
  db:
    image: mysql:5.7
    restart: always
    volumes:
       - db_data:/var/lib/mysql
    environment:
  MYSQL_ROOT_PASSWORD: p4ssw0rd!
networks:
  - back
  phpmyadmin:
    depends_on:
       - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - 8080:80
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: p4ssw0rd!
        networks:
      - back
     networks:
       back:
      volumes:
  db_data:

我已经运行docker-compose了,建立了,然后下来了,但是一切都一样.

I have run docker-compose up, build and down but everything is the same.

推荐答案

WordPress官方Docker映像将使用您设置的环境变量[

The official WordPress docker image will automatically configure wp-config.php using the environment variables you set [documentation].

如果有任何变量,例如 WORDPRESS_DB_HOST WORDPRESS_DB_PASSWORD 等,它们将用于构建 wp-config.php 在创建容器时保存文件.

If there are any variables such as WORDPRESS_DB_HOST, WORDPRESS_DB_PASSWORD, etc., they will be used to build a wp-config.php file upon container creation.

如果要提供自定义的 wp-config.php 文件,则需要确保没有相关的环境变量,并为修改后的文件创建卷映射,如下所示:

If you want to provide a custom wp-config.php file, you need to make sure there are no related environment variables, and create a volume mapping for your modified file, like so:

version: '2'
...
volumes:
  - ./wp-content:/var/www/html/wp-content 
  - ./wp-config.php:/var/www/html/wp-config.php
...

docker-compose up 上,Docker会将您的自定义wp-config.php加载到容器中,然后运行WordPress映像的

On docker-compose up, Docker will load your custom wp-config.php into the container and then run the WordPress image's docker-entrypoint.sh which updates the file with the values set in your environment variables.

这篇关于WordPress wp-config.php是否在Dockers中更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆