New Docker install on Ubuntu 21.04 for VM/Physical
3 min read

New Docker install on Ubuntu 21.04 for VM/Physical

Work with all your favorite apps and tools or create your own custom integrations using the Ghost API.
New Docker install on Ubuntu 21.04 for VM/Physical

Don't be a critic. I am not writer by any means of the imagination. I am just a hobbyist that likes to test out different scenarios.

Docker is a containerization system that works well with Ubuntu Server. We will use version 21.04 in this article. Please let me know if you have any questions about the install or configuration of this particular setup.

Expectations are that you have already got your OS installed and configured. If not you can follow this guide: Ubuntu Server Install

1 - sudo apt update
2 - sudo apt -y full-upgrade
3 - sudo nano -c /etc/hosts

4 - sudo apt -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common
5 - sudo curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
6 - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
7 - sudo nano -c /etc/apt/sources.list.d/<name_of_list> # change the repository from hirtsue to buster

change hirtsue to buster


8 - cd /var/tmp
9 - sudo curl -fsSL https://get.docker.com -o get-docker.sh
10 - sudo chmod +x get-docker.sh
11 - sudo sh get-docker.sh
12 - sudo docker version


13 - sudo docker info
14 - sudo docker ps -a


15 - sudo usermod -aG docker $USER
16 - sudo apt -y install docker-compose
17 - sudo docker-compose -version

At this point you should have a working Docker Host install. It is only a standalone host and is fully capable of running containers as you wish. Below I have described a swarm (cluster) install. This is a fascinating technology once you get to know it, I believe your large servers will disappear.

On the Master Node

18 - sudo mkdir -p projects
19 - sudo mkdir -p projects/portainer
20 - sudo touch projects/portainer/portainer-agent-stack.yml
21 - sudo nano -c projects/portainer/portainer-agent-stack.yml

DO NOT DO THIS UNTIL WORKER NODE IS DEPLOYED!

copy & paste the following in to the file in #21

version: '3.2'

services:
  agent:
    image: portainer/agent
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /var/lib/docker/volumes:/var/lib/docker/volumes
    networks:
      - agent_network
    deploy:
      mode: global
      placement:
        constraints: [node.platform.os == linux]

  portainer:
    image: portainer/portainer-ce
    command: -H tcp://tasks.agent:9001 --tlsskipverify
    ports:
      - "9000:9000"
      - "8000:8000"
    volumes:
      - portainer_data:/data
    networks:
      - agent_network
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]

networks:
  agent_network:
    driver: overlay
    attachable: true

volumes:
  portainer_data:

On the master node

21 - sudo docker swarm init

Do this one the master/leader node ONLY

22 - docker stack deploy -c agent-stack.yml portainer

On the worker node - Result of Docker swarm init command

docker swarm join --token <token info here>

If you have questions please feel free to contact me on the contact page with in this site or email me here mcooper@coopfire.com. I will answer as soon as I see it. Thanks for your time.