How to Connect and Edit Configuration Files for WordPress Running on Linux in a Docker Container Includes Changing Site URL

Here are the steps.

1) ssh to the linux host  (using SSH or Putty, or whatever)

change to Super User

sudo su

enter su credentials if required.  If you cannot switch to su mode, then just add sudo in front of all the below commands.

2) confirm docker is running… Display a list of all containers…

Docker Info

Docker ps  –a

Notice the ID of the container that you want to connect to: Is it running?  If not you can start it with:

Docker Start <ContainerID>

Since the container is running wordpress (or other web engine) it will not have an interactive session attached to it.  To create a new interactive

docker exec –it <ContainerID>  bash


You will then get a new prompt and automatically dropped into /var/www/html  Notice your prompt changed Smile


You will now see a list of the files and folders


You can now show a list of the environment variables with



You can now search for the files you want to edit using find <DirectoryName> –name <FileName>

see more about find at

If you wanted to search for functions.php file..

find . –name functions.php


I do not have an editor installed yet so I will install VIM

apt-get update

apt-get install vim


[Optional], add more features to VIM (aka: vi):

apt-get install vim-scripts vim-doc vim-latexsuite vim-gui-common

Long screenshot so skipping…

See for step by step instructions on how to exit with or without saving your file using VIM (aka: vi)

vim <filename.ext>

I am going to make a change in wp-config.php

vi wp-config.php


I want to change the URL of my site so I am adding



I also added a comment as you can see in the image.  The forward slash is a special character so

you need to add it after some text, then just delete the text.


<Escape> then :wq! to save changes

cat wp-config.php   then scroll up to see my changes in the file

To Exit out of the container…


you can also check the status of the container and restart it.


to exit out of ssh type


see also for more help on docker