Howto setup Docker on VPS to create multiple app hosting

The preparation of server is fully automated right now with Debian and Ubuntu operating systems (OS). Try to select the latest versions of these OSs to be fully updated and to get latest version of Docker. With DigitalOcean we prefer to select Debian 9.5 or Ubuntu 16.04 version. Installation usually takes around 5-10 minutes per server. You can contribute or report issue in goodservers/docker-server repository. What you need:

  • purchased VPS or dedicated server with root ssh access to the server
  • minimal experience with console app (eg. Putty for Windows)

Installation

Copy this command in console and through ssh command ssh root@your server ip login to your server and run.

Copy

Sometimes it happens that during the installation is shown some dialog window. It usually happens for config files (when new package contains new configuration options). But for now you can decide to "Keep installed version". The installation script updates your packages on server, installs docker, docker-compose utilities add user account and setup neeeded containers. Feel free to check the source code.

When the installation is finished. You could see the statuses for all docker containers:

terminal

The installation process is now waiting for the last necessary step for setup password less access to you server through user account.

terminal

This pair will be used for access from Gitlab to server in CI deploy task of each your projects.

  1. If you already have the pair private-public key you can select the first option and upload your public key. Press 1 and paste your public key. After that pressCTRL+x and save the configuration. This key will be paired together with user account.
  2. If you need new pair, just select the second option (press 2) and the console shows you your private key, so just copy and save it securely to future usage in Gitlab pipelines (this is last time when server shows you the private key and it's not stored on server).

👏
And that's it.
Now is your server prepared for deploying your apps.
Continue to setup your first app deploy.

To check that everything is fine, just visit your server's ip in browser. You should see the status 503 Service Temporarily Unavailable from nginx container. Thats because of no service is deployed and listening on this ip. When you typedocker ps into console. You should see the list of four running containers.

terminal

If something is broken, you can go through instalation step by step with guide, just add parameter -g to the installation script.