简体   繁体   English

访问正在运行的 docker 容器文件系统

[英]Access running docker container filesystem

I am developing a WordPress theme and set up the development environment using docker.我正在开发 WordPress 主题并使用 docker 设置开发环境。 My docker-compose.yml volume property looks like this;我的 docker-compose.yml 卷属性如下所示;

volumes:                                                                                                                
  - ~/WordPress/wp-content:/var/www/html/wp-content   

it mounts just the wp-content directory to the local machine.它只将 wp-content 目录挂载到本地机器上。 I now have to edit wp-config file which is in /var/www/html/ the docker image container.我现在必须编辑 /var/www/html/ docker 图像容器中的 wp-config 文件。 Can anyone here show me how to access and edit the wp-config file in the running docker container?这里有人能告诉我如何访问和编辑正在运行的 docker 容器中的 wp-config 文件吗?

You can run a shell terminal in the running container.您可以在正在运行的容器中运行 shell 终端。

  1. Get the container ID获取容器 ID

     docker container ls
  2. 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何访问在 docker 容器上运行的 wordpress? - How to access wordpress running on a docker container? 如何从同一台 wordpress 服务器(运行在同一台服务器上的 docker 容器)访问运行在 docker 容器中的数据库? - How to access the database running in a docker container from the same wordpress server(docker container running in same server)? 如何使用Docker Compose在主机和容器之间共享文件系统? - How can I share the filesystem between host and container with Docker Compose? Docker OSX-无法访问端口8080上的容器 - Docker OSX - Unable to access container on port 8080 无法访问 Docker 容器中安装的 Wordpress - Can't access Wordpress installed in Docker container docker-compose mysql 容器拒绝访问 wordpress 容器 - docker-compose mysql container denies access to wordpress container 如何为在 docker 容器中运行的 wordpress 站点配置 Ngix? - How to configure Ngix for wordpress site running ina docker container? 运行 Wordpress Docker 容器时启用 EXIF 支持 - Enable EXIF support when running Wordpress Docker container 无法通过 HTTPS 访问 WordPress docker 容器的静态文件 - Cannot access static files of WordPress docker container over HTTPS 即使状态正在运行,也无法访问Docker中配置的wordpress - Can not access wordpress configured in Docker even though its status is running
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM