forethought
forethought

Reputation: 3263

Access running docker container filesystem

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?

Upvotes: 1

Views: 2194

Answers (1)

nono
nono

Reputation: 1702

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

Upvotes: 1

Related Questions