How to install WordPress with Docker

Docker is a set of platform-as-a-service products that use operating-system-level virtualization to deliver software in packages called containers. Docker, inc. was founded by Solomon Hykes and Sebastien Pahl during the Y Combinator Summer 2010 startup incubator group and launched in 2011

By using the docker you can modernize your applications, accelerate innovation and Securely build, share and run modern applications anywhere.

Install Docker

Download the docker software from Docker official site for the operating system you are using and install it.

Define the project

  1. Create an empty project directory.

    You can name the directory something easy for you to remember. This directory is the context for your application image. The directory should only contain resources to build that image.

    This project directory contains a docker-compose.yml file which is complete in itself for a good starter wordpress project.

    Tip: You can use either a .yml or .yaml extension for this file. They both work.

  2. Change into your project directory.

    For example, if you named your directory my_wordpress:

  3. Create a docker-compose.yml file that starts your WordPress blog and a separate MySQL instance with a volume mount for data persistence:

Build the project

Now, run docker-compose up -d from your project directory.

This runs docker-compose up in detached mode, pulls the needed Docker images, and starts the WordPress and database containers.

Install WordPress via your Browser

Once the docker process finish, then open http://MACHINE_VM_IP:8000 in a web browser.

If you are using Docker Desktop for Mac or Docker Desktop for Windows, you can use http://localhost as the IP address, and open http://localhost:8000 in a web browser.

wordpress-welcome screen

Shutdown and cleanup

The command docker-compose down removes the containers and default network, but preserves your WordPress database.

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.