DEV Community

Discussion on: Hosting WordPress over HTTPS with Docker

Collapse
 
foresthoffman profile image
Forest Hoffman

Hi Roberto, thanks for taking the time to read it!

When focusing on the "The WordPress Containers" I think I might be missing some configuration, e.g. the nginx.conf inside the container named "nginx-wordpress". Does this mean you run the nginx container as is? Or is it using the same nginx.conf as the proxy?

No, the nginx-wordpress container has a separate configuration file from the nginx-proxy container. The nginx.conf file for the nginx-wordpress container is a run-of-the-mill configuration file. I believe mine is a slightly modified version of the default file that is created when you install Nginx on a normal machine. The key parts are the user and include statements. I'll add the configuration file to the write-up.

The container named "wp" refers to a Dockerfile "Dockerfile-wp" which is not on display, am I correct?

Ah yes, my apologies. I hadn't caught that. I believe the reason I overlooked it was, the Dockerfile ("Dockerfile-wp") runs some additional commands for debugging and such. I like to have a non-admin user and WP-CLI installed so that I can run some batch commands, should the need arise. The Dockerfile itself isn't crucial and the setup will work just as well if the build block in the Compose file were removed. I'll update that in the write-up.

Also, I think I might be missing the reason behind the volume "- ./wordpress:/var/www/html" as there is a container to provide this data? Or is this for any additional files being uploaded which will not be kept inside the data-container?

The reason that the wordpress directory exists on the host machine is to maintain the state of the WordPress docker container should it shutdown (this also goes for the mysql directory).

I would assume, correct me if i'm wrong, that the confusing part is the fact that the volume is mounted on both the wordpress and nginx containers. Nginx needs access the file structure that it is hosting, which happens to the same file structure that WordPress is being run on. Only mounting the wordpress directory to the WordPress container would be useless, since WordPress is about as interesting as a pet rock without a web server. On the other hand, only mounting the wordpress directory to the Nginx container would also be useless, as requests to the WordPress container wouldn't do anything.

Is this setup available on github somewhere?

No, I don't currently have anything up on GitHub regarding this. I built the write-up from what I have on my live server, so I took each piece and removed/replaced sensitive data with placeholders. For example, the MySQL password. Therefore, I don't have an anonymized version.

I'll make a reply when i've updated the write-up.

Thank you for your patience!

Collapse
 
caroga profile image
Roberto Gardenier • Edited

So, I've read your feedback, thanks for this!

I would assume, correct me if i'm wrong, that the confusing part is the fact that the volume is mounted on both the wordpress and nginx containers...

Thank you for explaining this, but this was actually not my confusion. I am confused about what the directory would actually hold.

The reason that the wordpress directory exists on the host machine is to maintain the state of the WordPress docker container should it shutdown (this also goes for the mysql directory).

Would this mean that the wordpress directory on the host machine already contains files ? Or would the modified / uploaded files be placed in there?

As for the rest of your feedback, thank you for clarifying. I will get to work with this in the next few days so I'll let you know how far it gets me.

Thank you!

Thread Thread
 
foresthoffman profile image
Forest Hoffman

The wordpress volume on the host machine holds the core WordPress files for the WordPress container (wp-config.php, wp-content/, wp-admin, etc.). Those files initially come from the WordPress container itself, when it's built. Since the wordpress volume is mounted to the container, from the host, you can do whatever you want with the files and they will propagate over to the container.