My First WordPress in a Container

/ What’s the fuss, with this Docker, all about? /

In short, software takes care of itself, using directives or configuration that you specify. Simplicity. Easy of use. You focus on important code rather than compiling libraries for days. And that was no fun, trust me.

Let’s demo it in this example. Let’s build a WordPress using Docker. No experience needed.

Point and click and few commands in the terminal. If you do not know what computer terminal is google it.

You are thinking how long this gonna take. Day, two …

More like 30min. Would you be interested in having your own version of WordPress running on your server or laptop?

Here’s how to:

 

1./ Docker for Windows or Linux? Does not matter. Get docker for your OS here: MAC or Windows

This is the Docker Engine software.

2./ Don’t have Docker Hub account? Get it here: DOCKER HUB

What’s that for? You need software [read docker image] to install your WordPress. The Docker Hub will do it for you.

3./ Now what? Run few commands from your shell [or terminal or power shell], just to warm up.

$ docker login
Login with your Docker ID to push and pull images from Docker Hub. 
If you don't have a Docker ID, head over to https://hub.docker.com to create one.

Username (XXXXX):
Password:
Login Succeeded
$ docker ps

$ docker images

$ docker info

docker ps – list running containers; docker images – shows local images; docker info – shows client info.

If no errors move along.

 

4./ Create docker-compose.yml file in your home directory.

Open it with text editor and add the following:

wordpress:
  image: wordpress
  links:
    - db:mysql
  ports:
    - 8080:80

db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: example

Replace example with your password.

Indentation is VERY IMPORTANT. This is how yml [or yaml] file reads document hierarchy.

 

5./ Run docker-compose in terminal in directory where above file is created:

docker-compose --project-name wordpress up -d

-d – runs a job in the background

Wait for 1-2 min.

DONE!

In your browser open the web page, if installed on local server or laptop, 127.0.0.1:8080. You can use IP as well [even better].

In my case: http://127.0.0.1:8080

 

6./ Check if service is running [run from terminal]:

$ docker-compose --project-name wordpress ps

 

7./ Download something called Kitematic

This is graphical interface for Docker on Windows and MacOS. Get it here: Kitematic

screenshot

More can be done but you have web site running and you did not have to download php, web server, wordpress, …..

Head to docs.docker.com for how-tos…

Leave a Reply

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