Published on

Setup docker in Ubuntu 18.04

1 min read
Table of Contents

Adding new user

adduser docker-login
usermod -aG sudo docker-login
su - docker-login

Changing ssh

nano /etc/ssh/sshd_config

ClientAliveInterval 300
ClientAliveCountMax 1
AllowUsers root docker-login
Port 234
MaxAuthTries 5
AllowTcpForwarding no                   # Disables port forwarding.
AllowAgentForwarding no                 # Disables the forwarding of the SSH login.

Refresh and restart


sshd -t

systemctl restart sshd

Fail2ban

apt install fail2ban
systemctl enable fail2ban

cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

nano /etc/fail2ban/jail.local

enabled = true
port = 234

systemctl restart fail2ban

Install Docker

sudo apt update

sudo apt install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce
sudo systemctl status docker
sudo systemctl enable docker
sudo usermod -aG docker ${USER}
su - ${USER}
id -nG
sudo usermod -aG docker docker-login
docker