Docker Wordpress
- Your yaml file works fine for me. The only thing I noticed is there's a missing database name variable in wordpress.environment (WORDPRESSDBNAME=wordpress) but this defaults to wordpress if not found. I'm pointing this out in case your actual copy has a db name other than wordpress. This is the compose file which works fine for me.
- WordPress with Docker Applications in containers run isolated from one another in the userspace of the host operating system sharing the kernel with other containers. This reduces the overhead required to run packaged software while also enabling the containers to run on any kind of infrastructure.
I’m using docker-compose to install wordpress. I see different approaches: – the official documentation doesn’t create any volume at all so an update of wordpress will just delete your wpcontent data. Docker is a software that enables the use and creation of Containers. To deploy WordPress Containers can be used. Here, we will discuss the benefits of using Docker and how you can install WordPress with Docker. Deploying containers with Docker isn't nearly as complicated as you might think. Jack Wallen walks you through the process of installing and deploying WordPress, with the help of Docker.
One of the most popular articles on my website is “Configure a local WordPress development on macOS from scratch”. I have recently used Docker a lot so I decided to tackle the same subject again but this time using containers.
This is not a Docker tutorial although by following along you learn how helpful this tool can be. I highly encourage you to familiarize yourself with few basic concepts like: images, containers, networks and volumes. Having a Docker app installed makes a lot of sense too. Regular readers know that I am a great friend with Homebrew. Yes, you can use it to download Docker too.
Wordpress + MySQL + phpMyAdmin #
To comfortably work with WordPress in a bare-bones local environment two components are required, although a third one is nice to have in some circumstances.
- MySQL or MariaDB database
- Database GUI like phpMyAdmin (optional)
Download agfa 1394 driver. Docker compose is a tool for creating multi-container Docker applications defined using single docker-compose.yml
file (.yml
and .yaml
extension works just fine). Sounds like a fantastic method to connect our three building blocks together. I will do my best to provide helpful descriptions and comments to each of the core building blocks. Start by making a new directory for your website, create a docker-compose.yml
in there and let’s finally get into the meat of this article.
That’s it — time to build our stack! Bear in mind that when you run it for a first time it is going to download all necessary stack images. Every subsequent invocation is going to be almost instant.
Voilà! #
Brand driver download. Hopefully you found this helpful. This simple setup helps me a lot to spin up a new WordPress from scratch in absolutely no time.
Ps. For simple websites like this one don’t use Wordpress. Use Hugo instead :)
Hey - Thanks for the nice write, its been helpful. I was windows for a long time and using wamp for my wordpress sites and thinking to switch over to docker now. Wanted to know your experience with the docker in comparison to standalone php-apache-mysql setup. Which one do you use? and does each of your wordpress site have a separate docker-compose file? or there is only one docker-compose file you use and have all your sites inside it.
Docker all the things :)
For each project I create new Docker compose file.
Hopefully that helps.
Have great day 🥑
On the screen where we have to put database details, what hostname should I put for mysql?
That should come preconfigured when you set it up like I did. The piece of config that decides about it is this:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpressThanks for reply, I am asking about this screen. What information should I put here.. https://uploads.disquscdn.c..
What do I do if the ports are already in use? I attempted to kill the ports used but was not able to, so I tried changing them in the config file but still couldn't get this to run.
Hi Pawel! Thanks for nice starting point to create WordPress in seconds but I have question. I'm using PhpStorm and when it only showing all from `wp-content` directory PhpStorm does not hint the core functions because there are not in project. Do you know how to configure it to use the function hints?
Hi.
I see what is going on. I am affraid that in this case you have to expose a project root level in your volume
['./:/var/www/html']
to make PhpStorm correctly infer WP core methods. I am not a PhpStorm user and potentially there is a much better way. Sorry for being not too helpful.Have a great day 🥑
Hi Pawel! Nice tutorial, thanks! Question though - how would you mount php.ini ? I'm using Ubuntu on WSL.
Great tutorial. However, I also need .htaccess file on my wp folder because some plugins and also WP itself is changing it. How to do that?
Hi Pawel, thanks a lot for this tutorial. I followed your steps, but I cant edit the files of the volume. They all have user `www-data` while my user is adam. File permission is 644, so I can't even edit them, if I add `www-data` group to `adam`. Any advice how to fix it? Also asked this here: https://stackoverflow.com/q..