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.
ssh-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
Create server
Create the firewall for the server
IP address of our machine
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.
A XX.XX.XX.XX yourdomain.com
CNAME * 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.
Host youtube1.yourdomain.com
IdentitiesOnly yes
IdentityFile ~/.ssh/yournewlycreatedkey # Not the pub file
Related Posts
Docker Deployment using docker swarm
In this post we will see how to setup docker swarm for your development environment.
Prepare and deploy the microservice
In this post we will see how to deploy the microservice solution to the our server.
Deploy redis, rabbitmq, seq, registry and postgres in docker swarm
In this post we will see how to deploy redis, rabbitmq, postgres and registry.