问题描述
我正在开发WordPress主题,并使用docker设置开发环境.我的docker-compose.yml卷属性如下所示;
I am developing a WordPress theme and set up the development environment using docker. My docker-compose.yml volume property looks like this;
volumes:
- ~/WordPress/wp-content:/var/www/html/wp-content
它仅将wp-content目录安装到本地计算机.我现在必须编辑/var/www/html/docker图像容器中的wp-config文件.这里有人可以告诉我如何访问和编辑正在运行的Docker容器中的wp-config文件吗?
it mounts just the wp-content directory to the local machine. I now have to edit wp-config file which is in /var/www/html/ the docker image container. Can anyone here show me how to access and edit the wp-config file in the running docker container?
推荐答案
您可以在正在运行的容器中运行Shell终端.
You can run a shell terminal in the running container.
-
获取容器ID
Get the container ID
docker container ls
运行终端
Run the terminal
docker container exec -it container_ID "/bin/bash"
但是,无论您进行什么更改,都不会永久保留.您还必须映射此体积.
But, whatever change you do, it will not be persisted. You have to map this volume also.
volumes:
- ~/WordPress/wp-content:/var/www/html
这篇关于访问正在运行的Docker容器文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!