WordPress with Docker

Tagmalogic
tagmalogic
Published in
3 min readMay 25, 2020
WordPress with Docker

Hey, here are a few steps to get your local installation of WordPress on Docker. Need to say that this article is not for production use and is rather a quick start point on which you can build later on based on your needs. But for learning… should be just what you need, I hope.

Even more, my intention here is to get you quickly set up and not deep dive in explaining all the concepts and components used.

Oh, one more thing, this article was put together using WordPress 5.2.2 but should be fairly similar for most versions.

Docker

First of all you will need to have Docker and Docker Compose installed locally, on your computer. You can do it from here. Once done, check in your terminal that the installation was successful with:

docker --versiondocker-compose --version

When running the above commands, you should see a version displayed.

Now, create a new file called, docker-compose.yml and add the following code to it:

version: "3.3"services:db:image: tagmalogic/simplewebappmysql:1.0volumes:- db_data:/var/lib/mysqlrestart: alwaysenvironment:MYSQL_ROOT_PASSWORD: somewordpressMYSQL_DATABASE: wordpressMYSQL_USER: wordpressMYSQL_PASSWORD: wordpresswordpress:depends_on:- dbimage: tagmalogic/simplewebappwp:1.0ports:- "8000:80"restart: alwaysenvironment:WORDPRESS_DB_HOST: db:3306WORDPRESS_DB_USER: wordpressWORDPRESS_DB_PASSWORD: wordpressWORDPRESS_DB_NAME: wordpressvolumes:db_data: {}

This will spin up, on your local machine, a Wordpress instance that is available on port 8000. Should this port be already used by other application you can go ahead and adjust it, change it in docker-compose.yml file to a port suitable for you.

In fact there are two images that we’ve build containers from. One image for the database (tagmalogic/simplewebappmysql:1.0) and one for WordPress itself (tagmalogic/simplewebappwp:1.0).

Now, run in your terminal windowdocker-compose up -d and then navigate to http://localhost:8000 . You will be prompted to progress with the Wordpress installation.

Wordpress installation

Choose your “language” and click continue. I’ll choose English (United States)

Install WordPress — choose language

Insert the details in the form below…

Install WordPress — install details

I’ll be using the following:

  • Site Tilte — WordPress Test Site
  • Usernamemagicman
  • PasswordpasswordWP (well obviously, this is just a test site but don’t use such a weak password)
  • Check confirm use of weak password if you see this option
  • Your Email notreallymine@notarealdomain.notarealdomain

… hit Install WordPress.

After a short while you should be directed to the login page as below. Go ahead and login with the username and password you choose above.

WordPress — Login

Here you are, you are shown the WordPress Dashboard :)

WordPress — Dashboard

I hope this quick tutorial was of help for you!

See you!

--

--

Tagmalogic
tagmalogic

Where journey meets the destination — magic tech!