Alan Santos

Software Engineer

Installing Docker + Portainer on Raspberry Pi OS

Hi, in this post we will install Docker on Raspberry Pi and Portainer to manage our container using any web browser from another computer. Docker ables to us to install/uninstall tons of softwares with a simple command.

Installing Docker

First of all, lets install all prerequisites:

sudo apt-get install apt-transport-https ca-certificates software-properties-common -y

Now, we can install Docker:

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh

After Docker installation, lets put pi user on Docker group to run commands without sudo:

sudo usermod -aG docker pi

To keep docker update, lets add Docker repository Raspberry Pi OS:

  1. Import Docker CPG key
    • sudo curl https://download.docker.com/linux/raspbian/gpg
  2. Edit repository sources to add Docker Repo
    • sudo nano /etc/apt/sources.list
  3.  Add the following line:
    • deb https://download.docker.com/linux/raspbian/ stretch stable
  4. Press Ctrl+X and Enter to save the file
  5. Press Y to confirm
  6. Run sudo apt-get update
  7. Run sudo apt-get upgrade
  8. To start Docker, run sudo systemctl start docker.service
  9. To ensure that Docker will start on boot, run sudo systemctl enable docker.service

Install Portainer

To install Portainer:

  1. Create portainer Docker volume with command docker volume create portainer_data
  2. Run the command bellow to create Portainer container:
docker run -d -p 9000:9000 \
--name portainer \
--restart unless-stopped \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data portainer/portainer

--restart unless-stopped will configure the container to aways start unless receive a stop command

You can check check the container running just typing docker ps on the command line. To access Portainer, use any browser like Chrome or Firefox and type your Raspberry IP address and use port 9000, in my case http:192.168.15.26:9000

In your first access, configure your username and your password and click on Create User:

In the next screen, choose the Local option and click on Connect:

Thats it! Your Portainer is configured to manager your container:

Clicking on the first option, or typing on the URL http://YOUR_IP_ADDRESS:9000//#/dashboard, you can see curious informations about your Docker environment

Maybe is time to delete some Docker images to free my MacBook SSD.. kkk

That’s it for now. Based in this configuration, we will do cool thing to automate your house using on the future the Home Assistant as Docker Container. Bye!

EnglishPortuguês