Raspberry Pi: Docker & Portainer - msandholz/RaspberryPi-Tutorials GitHub Wiki

Install Docker

  1. Login with SSH 2a. Download Docker with: pi@octopi:~ $ curl -sSL https://get.docker.com 2b. Install Docker with: pi@octopi:~ $ sh get-docker.sh 2c. Run Docker as non-Root user: pi@octopi:~ $ sudo usermod -aG docker pi 2d. Check Group: pi@octopi:~ $ groups pi

  2. Enable Docker as service: pi@octopi:~ $ sudo systemctl enable docker

  3. Start Docker: pi@octopi:~ $ sudo systemctl start docker

  4. Request Docker status: pi@octopi:~ $ sudo systemctl status docker

    ● docker.service - Docker Application Container Engine
        Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
        Active: active (running) since Fri 2021-01-08 16:22:22 GMT; 3min 18s ago
           Docs: https://docs.docker.com
       Main PID: 17944 (dockerd)
           Tasks: 13
          CGroup: /system.slice/docker.service
                  └─17944 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
    
  5. Docker command line reference: https://docs.docker.com/engine/reference/commandline/cli/

  6. List all installed Docker containers: pi@octopi:~ $ sudo docker container ls --all

    CONTAINER ID   IMAGE                 COMMAND        CREATED          STATUS                     PORTS     NAMES
    9a76ff637b20   portainer/portainer   "/portainer"   29 minutes ago   Exited (2) 8 minutes ago             portainer
    
  7. Stop one or more running containers: pi@octopi:~ $ sudo docker container stop portainer

  8. Start one or more stopped containers: pi@octopi:~ $ sudo docker container start portainer

Install Portainer

Pre-requirements: Docker is installed!

  1. Login with SSH

  2. Create volume with: pi@octopi:~ $ sudo docker volume create portainer_data

  3. Install Portainer with: pi@octopi:~ $ sudo docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

  4. Access Portainer in browser: http://<ip-adress>:9000

  5. Create new password

  6. Click on Local and hit the Connect-Button

  7. Click on Container List

  8. Add new Container hello world

    • click on Add Container
    • fill in Name my-first-container and Docker.io image hello-world
    • click on deploy the container

  9. Update Portainer

    • get latest version: pi@octopi:~ $ sudo docker pull portainer/portainer
    • stop portainer: pi@octopi:~ $ sudo docker stop portainer
    • remove portainer: pi@octopi:~ $ sudo docker rm portainer
    • run new version of portainer: sudo docker run -d -p 8000:8000 -p 9000:9000 --name Portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
⚠️ **GitHub.com Fallback** ⚠️