Anto Subash.

Posts in the Series

Part 1. Setting up Ubuntu Server with docker in Hetzner (this post)

Part 2. Setting up docker swarm with traefik and portainer

Part 3. Deploy redis, rabbitmq, seq, registry and postgres in docker swarm

Part 4. Deploy the microservice in docker swarm

Table of contents

Intro

In this post we will see how to setup a ubuntu server for our docker deployment.

Prerequisites

  • Hetzner cloud account

you can use the referral link here and get 20 Euro to play around. https://hetzner.cloud/?ref=ENhA4rCZ5JUM

Creating ssh key

we will use ssh key to login to the server. so lets first create a ssh key.

1ssh-keygen -t ed25519 -C "demo@antosubash.com"

this command will create a ssh key.

Create ubuntu machine with docker

For this we will the hetzner apps. Hetzner provides machine with docker CE. this will save us some time.

Add ssh key to hetzner project

Add ssh to your hetzner project

Add ssh to your hetzner project

Add ssh to your hetzner project

Create server

Create Server

Create Server

Create Server

Create Server

Create Server

Create Server

Create Server

Create Server

Create the firewall for the server

Create firewall

Create firewall

Create firewall

Create firewall

Create firewall

IP address of our machine

IP address

Add DNS entry

Now you have to add a DNS entry for your newly created machine. you can fine the the IP address of the machine in the Hetzner server page.

We need to add A record and a CNAME record.

1A XX.XX.XX.XX yourdomain.com
2CNAME * yourdomain.com

For example this is how my sample entry looks like

Record Host Value A youtube1 95.217.191.119 CNAME * youtube1.antosubash.com

This might take some time to reflect so wait for a while to verify it.

Verify DNS entry

To verify dns entry we will use a tool called dig.

you can find it here https://toolbox.googleapps.com/apps/dig/#A/

Make sure your domain is pointing to your ip and your subdomain is pointing to your domain

yourdomain.com -> XX.XX.XX.XX subdomain.yourdomain.com -> XX.XX.XX.XX

So both your domain and subdomain should point to the same IP Which is the IP of the machine we just created.

Update ssh config

ssh config file can be "~/.ssh/config"

In the config file add a entry for the newly created server.

1Host youtube1.yourdomain.com
2   IdentitiesOnly yes
3   IdentityFile ~/.ssh/yournewlycreatedkey # Not the pub file
Buy Me a Coffee at ko-fi.com