Install Portainer on Debain

Let’s get Portainer installed!

You can either run these commands as ‘sudo’ or run ‘sudo -i’ to run these commands as root.

All we need is at least SSH access and/or ftp access(to make it easier for file editing), but that is optional if you just want to quickly get this installed.

Quick Rundown: All we need to do is SSH into the device we want to install Portainer on, configure the ‘compose.yaml’ file and run it.

First, SSH into the device with your tool of choice. Ex. Putty, CMD, Terminal, etc.

In my case, I use nano:

Edit compose file with nano

Paste this for the base config:

services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: always
    ports:
      - "9443:9443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/hassio/home_assistant/portainer_data:/data
    environment:
      - TZ=change_me
YAML

So we have:

services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
YAML

Which defines the name of the container to Docker ‘portainer’, you will use this to modify the container later.

image: portainer/portainer-ce:latest
YAML

Tells Docker what image to run. ‘portainer/portainer-ce‘ is Portainer’s Community Edition, ‘:latest’ is the tag, it will pull the newest latest tag on startup.

restart: always
YAML

This is the Docker restart policy. If the container stops (or the host reboots), Docker will automatically try to start it.

    ports:
      - "9443:9443"
YAML

Maps host port 9443 to container port 9443. Portainer uses 9443 for the HTTPS web UI by default. After it starts, you’ll access Portainer at https://<host-ip>:9443.

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
YAML

This binds the Docker socket into the container. This is what gives Portainer the ability to control Docker (list containers, start/stop, create volumes, etc.). VERY powerful: any process that can talk to the Docker socket can control the Docker daemon (and therefore the host).

    volumes:
      - /home/hassio/home_assistant/portainer_data:/data
YAML

A host directory mounted into the container’s /data — used by Portainer to store its state (users, settings, DB). This ensures data persists after container upgrades.

Make sure to create a folder so Portainer can store its data. In my case, I put it under my users folder ‘/home/hassio/home_assistant/portainer_data’, but you would probably want to do something like ‘/home/’your username’/portainer_data’ instead. If you copied the file, make sure to change ‘/home/hassio/home_assistant/portainer_data’ to what suits your needs.

    environment:
      - TZ=change_me
YAML

This sets the timezone inside the container so logs and scheduled tasks use that timezone. Cosmetic but helpful. Make sure to change the timezone name or delete it.

All you have to do next is change the Timezone, based on the name you find here.

You can see my post on how to set the timezone here if you need more info on that.

sudo docker compose -f compose.yaml config
Bash

All you need to do next is run that command, replacing ‘compose.yaml’ with your filename, to validate your Compose file.

sudo docker compose -f compose.yaml up -d
Bash

That brings the container up.

sudo docker compose ps
Bash

You can see the status of your running containers with that.

sudo docker ps --filter name=portainer
Bash

Or use this one to specifically see the status of Portainer if you have multiple containers running. Make sure to change ‘portainer’ to the name that was used in the configuration file.

sudo docker compose logs -f portainer
Bash

With this one, you can see the log file.

Now your Portainer container should be up and running!

Navigate to ‘https://<host-ip>:9443’, replacing the port number if you changed it in the compose file and replacing ‘<host-ip>’ with the device’s actual IP address.

Make sure to create a strong password, as anyone who has it will be able to change your containers and potentially do malicious things.

Here is the Portainer Installation Documentation if you wish to view it.

I hope this helped you out! Have a great day and have fun building containers!

Leave a comment if you need any help. I’ll be glad to support you!

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.