githubEdit

Portainer

Portainerarrow-up-right is a lightweight, web-based graphical user interface (GUI) designed to simplify container management for Docker, Docker Swarm, Kubernetes, and Azure ACI

Alternatives to Portainer

There are many alternatives to portainer. In fact, you don't even need to use it at all! It just makes configuring docker set ups easier.

There are many other alternatives, such as:

However, we won't be going into detail for this session - we shall use portainer mainly just because I'm familiar with it :D

Portainer Set Up

1

Write Docker Compose File

First, let's navigate to a good place to write our docker files. Typically, I just write it in my home directory

cd /home/<username> &&
mkdir -p docker-compose/portainer &&
cd docker-compose/portainer &&
vim docker-compose.yml
docker-compose.yml
services: # each item under services would be a container
  portainer:
    container_name: portainer
    image: portainer/portainer-ce:sts
    restart: always # what to do when the container crashes / exits
    
    volumes: # where to mount the volumes into the container
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    ports: # what ports we want to publish
      - 127.0.0.1:9443:9443

volumes: # docker volume create ...
  portainer_data:
    name: portainer_data

networks: # docker network create ...
  default:
    name: portainer_network
2

Running portainer

In the same directory that you wrote the docker-compose, you should now start the docker container:

docker compose up

After it starts up, you can always see check the running process by running:

docker ps

Note how 0.0.0.0:9443->9443/tcp, this means that later when we expose to the internet, we need to connect to the host port 9443 to be able to connect to this portainer container!

3

Make Portainer Accessible from the Internet

We can use Cloudflare Tunnels for this. Read ahead to Exposing to the Internet, then come back!

4

Configuring Portainer

You should now be seeing a screen like this. Create a username and password, and store it safely!

How to deploy Docker Compose on Portainer?

Portainer calls Docker Compose as Stacks. So, we can head to Dashboards > Stacks > Add Stacks in order to add new docker compose containers.

Now, we can go ahead with Let's Host Things!, where we will walk through using Portainer by hosting a service.

Portainer UI

Home Page:

Dashboard:

Managing Containers:

Container Details:

For more details, please refer to Portainer's Guide:

Last updated