Today the trend in every company is to use a DevOps architecture as a magical solution for everything. Translated for the developer not only he has to build the software but deploy it as well.

The standard solutions are platforms like OpenShift or CloudFoundry. These solutions are oriented and affordable for companies but way too expensive for most of the developers that want to publish their ready to grow application.

Our goal

Easily automatically deploy more applications on the web (, using a ‘cheap’ (cheaper than the DevOps platforms) but powerful server.

To give an idea about the prices a small app running on a DevOps cloud solution (1 GB RAM) cost around $30 per month, with a basic VPS and docker only $3-5 (2GB RAM for more apps!).

What we need

VPS and Docker

Install Docker on your server using the official Docker documentation or the instructions of your server provider. You can pull your own image or an image from For instance my Angular and Java demo

docker pull javaee/angular2-java-hello-world

to run the app on port 8080

docker run --name angular -d -p 8080:8082


If you prefer you can deploy directly your web app on the server but you risk to miss most of the fun. 😉

Create a VirtualHost

You will run multiple docker containers in server, for this reason is better to have a proxy that redirect the external requests to the correct applications.

Example: -> localhost:8090 -> localhost:8088

In ubuntu you have to install apache2

sudo apt-get install apache2
sudo apt-get install libapache-mod-jk

activate the features to use the proxy:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod ssl
sudo a2enmod proxy_balancer

Create a file with your host configuration in the following path:


the file name suffix has to be .conf e.g.

sudo vi ./mydomain.conf

Apache Virtual Host configuration for Tomcat

# *.80 listen all the requests at the port 80
<VirtualHost *:80>

# the following rules apply for the requests 
# to the server

# aliases of our server name (answer to this calls too)
ServerAlias * *

# email of the administrator
ServerAdmin webmaster@localhost

ProxyPreserveHost On

# where to redirect the request to
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

# root of the target (doesn't apply for tomcat)
DocumentRoot /var/www

To activate this rule:

sudo a2ensite mydomain.conf _


Deactivate the default answering for the port 80 (apache welcome) :

sudo a2dissite 000-default-conf _


Restart your apache service

sudo /etc/init.d/apache2 restart

You can check the status of your service:

systemctl status apache2.service

Your application running on port 8080 (if Java based) is accessible at the url:, port 80.

If your application doesn’t answer from internet it is possible that the port 80 of your server is not closed. You can test in your server to see if the application is correctly deployed with:

curl localhost

If your terminal shows the content of your application home page it mean that the deploy is correct.


Continue … Docker publish and deploy, cheat sheet