1

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?

5
  • No, you need to change the configuration and recreate the container, at least. Commented Mar 12, 2017 at 10:22
  • That"s a relief. Any clue on accessing and editing the file? Commented Mar 12, 2017 at 10:25
  • Simply add another volume to your container Commented Mar 12, 2017 at 10:30
  • @mike I do not want add another volume because I just need to edit the file once or twice in the whole theme development process. Commented Mar 12, 2017 at 10:35
  • This is against best practices. Your app will stop working when you recreate your container Commented Mar 12, 2017 at 16:47

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

2 Comments

How to make it persisted so that when I start the container tomorrow the changes still be in effect.
You need to add the volume like I said previously

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.