Access running docker container filesystem

纵饮孤独 提交于 2021-02-10 14:17:18

问题


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   

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?


回答1:


You can run a shell terminal in the running container.

  1. Get the container 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


来源:https://stackoverflow.com/questions/42746218/access-running-docker-container-filesystem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!