Bobcares

Deploy Multiple WordPress Applications On Ubuntu – Using Docker

by | Jan 25, 2021

Wondering How to Deploy Multiple WordPress Applications On Ubuntu?

Docker is one of the most popular methods used to save, set up and share server environments using containers.

Containers allow to package up any application with all parts of it such as libraries and other dependencies and deploy it as one package.

Docker is designed in such a way to make it easier to create, deploy, and run applications with the help of containers.

At Bobcares, we often get requests from our customers to deploy multiple WordPress applications on Ubuntu servers.

Today let’s see the steps that our Support Engineers follow for the deployment of multiple WordPress Apps as a part of our Server Management Services.

 

How to Deploy Multiple WordPress Applications On Ubuntu 

In this article, we will be using the Docker Linux Container Engine to deploy multiple WordPress applications on Ubuntu. Docker uses containers to deploy applications in a hassle-free manner.

Deploy Multiple WordPress Applications On Ubuntu

 

Here we will be creating WordPress installed Docker images, which will allow us to run another WordPress site on any VPS, by a single command using Docker.

The steps that our Support Techs follow are given below:

 

Installing Docker on Ubuntu

1. We can use the following command to update the droplet and ensure aufs support is available.

$ sudo apt-get update
$ sudo apt-get -y upgrade
$ sudo apt-get install linux-image-extra-`uname -r`

2. Add the Docker repository key to apt-key for package verification with the command below:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

3. Next we can add the Docker repository to sources

$ sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\
> /etc/apt/sources.list.d/docker.list"

4. Now we will update the repository first, with the following command:

$ sudo apt-get update

5. Finally, we will download and install Docker with the following command:

$ sudo apt-get install lxc-docker git

6. To enable forwarding with UFW we need to edit the UFW configuration:

$ sudo nano /etc/default/ufw

Replace:

DEFAULT_FORWARD_POLICY="DROP"

with:

DEFAULT_FORWARD_POLICY="ACCEPT"

7. Save and exit the configuration file.

8. Then reload UFW with the following command:

$ sudo ufw reload

9. To allow remote connections for using the docker daemon remotely we need to allow the default port of Docker which is 4243.

$ sudo ufw allow 4243/tcp

 

Some basic commands used for Docker

1. We can run the docker daemon with the following command:

$ sudo docker -d &

2. Client usage:

sudo docker [option] [command] [arguments]

It must be kept in mind that Docker requires sudo privileges to work as it uses sockets owned by root.

We can get a full list of all available commands by simply calling the client with the following command:

$ docker

 

Creating WordPress Containers

We will be using the out-of-the-box WordPress image ‘tutum/wordpress’.

In order to create containers from this image, we need to pull (download) it first using the following command:

$ docker pull tutum/wordpress

Once the image is ready, with a single command we can create dockerized WordPress instances.

1. To Create a Publicly Accessible WordPress Container

Run the following command to create a container that is reachable from the outside on a port we specify (e.g. 80):

$ docker run -p 80:80 tutum/wordpress

This command helps to create a WordPress instance that will accept connections from outside on the default HTTP port 80.

2. To Create a Locally Accessible WordPress Container

Run the following command to create a locally accessible container.

$ docker run -p 127.0.0.1::80 tutum/wordpress

Now Docker will create a container and provide its ID and then dynamically allocate a port.

We can find out which port the container is using with the port command given below:

docker port [container ID] [private port number]
$ docker port 9af15d56fdf8a587 80
# 127.0.0.1:49156

From the output, we can see that the container is accessible only on the localhost on port 49156.

We can use this address to redirect connections from a reverse-proxy using the following command:

docker run -p 127.0.0.1:[local port]:80 tutum/wordpress
$ docker run -p 127.0.0.1:9091:80 tutum/wordpress

Now the WordPress instance is locally accessible at port 9091.

[Need assistance to deploy your WordPress Apps? We are happy to help you!]

 

Conclusion

To conclude we saw how to deploy multiple WordPress applications on Ubuntu with Docker. Also, we saw the steps that our Support Engineers follow to do this easily.

Are you using Docker based apps?

There are proven ways to get even more out of your Docker containers! Let us help you.

Spend your time in growing business and we will take care of Docker Infrastructure for you.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.