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 […]
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
[

](/wp-content/uploads/2017/02/image-1.png)
Notice the ID of the container that you want to connect to: Is it running? If not you can start it with:
Docker Start
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
[
![]()
](/wp-content/uploads/2017/02/image-2.png)
You will then get a new prompt and automatically dropped into /var/www/html Notice your prompt changed
![]()
ls
You will now see a list of the files and folders
[
![]()
](/wp-content/uploads/2017/02/image-3.png)
You can now show a list of the environment variables with
printenv
[
![]()
](/wp-content/uploads/2017/02/image-4.png)c
You can now search for the files you want to edit using find
see more about find at https://www.cyberciti.biz/faq/how-do-i-search-my-linuxunix-server-for-a-file/
If you wanted to search for functions.php file..
find . –name functions.php
[
![]()
](/wp-content/uploads/2017/02/image-5.png)
I do not have an editor installed yet so I will install VIM
apt-get update
apt-get install vim
[
![]()
](/wp-content/uploads/2017/02/image-6.png)
[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 http://itproguru-app.azurewebsites.net/expert/2016/11/how-to-exit-quit-vi-editor-without-saving-changes-step-by-step/ for step by step instructions on how to exit with or without saving your file using VIM (aka: vi)
vim
I am going to make a change in wp-config.php
vi wp-config.php
[
![]()
](/wp-content/uploads/2017/02/image-7.png)
I want to change the URL of my site so I am adding
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
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.
[
![]()
](/wp-content/uploads/2017/02/image-8.png)
cat wp-config.php then scroll up to see my changes in the file
To Exit out of the container…
exit
``
you can also check the status of the container and restart it.
[
![]()
](/wp-content/uploads/2017/02/image-9.png)
to exit out of ssh type
exit
``
see also [http://itproguru-app.azurewebsites.net/expert/2016/10/docker-create-container-change-container-save-as-new-image-and-connect-to-container/](http://itproguru-app.azurewebsites.net/expert/2016/10/docker-create-container-change-container-save-as-new-image-and-connect-to-container/) for more help on docker