In first part we securely set up virtual machine and install nginx with https support by Let’s Encrypt certbot. In this second part we setup Docker and Portainer. Portainer we will use for docker comfortable control. Let’s start!
Install docker
You need to prepare your virtual machine to install docker - set up the Docker repository.
Set up the repository
First you need to update apt index and install some dependencies, which needed for docker install. Update the apt package index:
sudo apt-get update && \
apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
Next add Docker’s GPG key from docker.com:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
You could verify your received key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88:
sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker@docker.com>
sub rsa4096 2017-02-22 [S]
Finally, add repository to your system:
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
Install docker
First update your apt index again.
sudo apt-get update
Now your system are ready for install docker:
sudo apt-get install docker-ce docker-ce-cli containerd.io
Set up Portainer
For deploy and update we will use docker compose. Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Here is an example compose file:
version: "3.7"
services:
portainer:
image: portainer/portainer:latest
ports:
- 127.0.0.1:9000:9000
command: --host=unix:///var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer-data:/data
networks:
- aviation
deploy:
mode: global
volumes:
portainer-data:
driver: local
networks:
hugo:
name: hugo
attachable: true
Save it as host.yml. To start portainer simple run follow command:
docker-compose -c host.yml up
Next open portainer on https://«your host»:9000
It will ask to create user and set password for it:
Next you will show follow picture:
Previous post » Set up a landing page on Hugo: ssh, fail2ban, nginx, certbot
Next post » Set up hugo an gitlab ci