Setup Ubuntu, Tailscale & Docker
Self hosted PayloadCMS and PostgreSQL website on Docker
3 min read
Published Jun 17 2025, updated Jun 19 2025
Guide Sections
Guide Comments
So you this guide assumes you have purchased a bare metal server or VPS with Ubuntu installed and the company you purchased this with have given you SSH login details and a public IP address.
Update Ubuntu
First thing to do is make sure all the packages are up to date. So SSH in to your server and then,
Update the package lists:
Upgrade the installed packages:
Install Tailscale
We are going to add the server to Tailscale so that we can access Portainer and connect directly to PostgreSQL using GUI tools etc but not make these available over the public IP address, only by devices on our Tailscale VPN network.
I assume you already have a Tailscale account, if not visit Tailscale.com and signup and install on your local computer so that machine is on a Tailscale network.
Go to the admin console on the Tailscale website, click 'Add device' and select 'Linux server'. Scroll to the bottom and click 'Generate install script'.
Copy the provided script and paste it in to your SSH console connected to your server.
Now make sure Tailscale is running and will automatically restart when the server reboots:
Verify it is working by running:
You should see output indicating that the service is active and running.
Now we need to log out of standard SSH and SSH back in using the Tailscale IP address as later in this guide we will be locking down access from the main public IP address.
Locate your Tailscale IP address for this server on the Tailscale website Machines tab on the admin console.
SSH in to the server using this IP address and your user and password from before and port 22.
You should now be connected to your server over SSH again but on the Tailscale IP.
Install docker
Make sure you haven't installed docker via Snap when installing Ubuntu and it gives you a list of Snap applications to add as the Snap version of docker will give you all sorts of problems! If you have uninstall it and reinstall using the method below.
Setup dockers apt repository:
Install the docker packages:
Now we need to add the current user to the docker group so that you don't need to run sudo before all commands.
Add the docker group:
Add the user to the docker group:
You might need to log out and back in again for the user in group change to take effect.
You can verify everything is working by running:
Which should display the installed version.
Which would list the current containers, however as you are a fresh install it will just show the empty headings for the table if its all ok.
Now we are going to convert this docker instance in to a docker swarm. This makes it easier in the future if you want to expand and add more server nodes. Its not strictly needed if you are only ever going to have the 1 server, however the rest of this guide will need tweaking as we will be adding stacks and services which are only supported on docker swarm mode. Personally I prefer working with swarm mode, even with a single server.
To create a new swarm, run:
Replacing <MANAGER-IP> with the IP address of your server (not the Tailscale IP)
This will display a message of how to add other nodes to your Swarm but as we are only setting up the single server now, we can ignore that.