This lab is part of the Enterprise service management IT00EB95-3004 course.

Deploy Portainer

Start with installing Docker on the server:

sudo apt update
sudo apt install docker.io -y
 
# Add the current user to the Docker group to run Docker without sudo:
sudo usermod -aG docker $USER
 
# Relogin to apply configuration
logout
 
# Create a volume named portainer_data and deploy the Portainer Server container:
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Networking in Portainer

Manage portainer network in order to allow communications by hostnames in isolated network:

Navigate to Home  Local  Networks  Add network:

  • Name: yourname_net
  • Driver: bridge
  • IPv4 Network configuration:
    • Subnet: 192.168.16.0/24
    • Gateway: 192.168.16.1

Create an Nginx container and attach to the network:

  • Navigate to Home Local Template Application and search for Nginx and deploy the container.
  • Under Container Details Connected Networks, join the container to the newly created network.

At this point, the network has assigned to an endpoint, which is the Nginx container that we have just created. The attempt to remove the network would not be allowed.

Only after you has successfully removed the container, the Portainer would allow deletion of network.

Deploy Redis & Nginx containers from templates on the same network

Deploy Nginx container from template:

  • Navigate to Home Local Template Application search for Nginx to deploy:
    • Name: nginx_yourname
    • Network: yourname_net

 Deploy Redis container from template:

  • Navigate to Home Local Template Application search for Redis to deploy:
    • Name: redis_yourname
    • Network: yourname_net

Exec into Nginx & ping Redis

Open nginx_yourname container details, under Container Status Console, connect to the console and run the command ping redis.

It is not possible at the moment because the current container has not installed the ping utility.

To install ping tool, run following commands inside the container:

  • apt update
  • apt install inetutils-ping -y

After the installation, ping is now possible.

Deploy multiple containers on the network

Navigate to Home Local Container and scroll to the right then click on Add container:

  • Name: alpine1_yourname
  • Image: alpine:latest
  • Advanced container settings:
    • Commands & logging:
      • Console choose Interactive & TTY (-i -t)
  • Network: yourname_net

Deploy a second alpine container and name it apline2_yourname with the same configuration as alpine1_yourname container.

Exec into alpine1_yourname container, modify command option to /bin/sh, then connect.

Run the command: ping  alpine2_yourname to test connectivity.

Shared Volumes in Portainer

Creating a shared disk for both machines to access.

Navigate to Home Local Volumes and create a volume called yourname_shared_data.

Modify alpine1_yourname and alpine2_yourname:

  • Click on container
  • Actions  Duplicate/Edit
  • Advance container settings Volumes + map additional volume:
    • Container: /shared_yourname
    • Volume: yourname_shared_data (Writable)
  • Redeploy container

Now both machine can access shared volume at /shared_yourname and making any changes.