How to Install Docker and Portainer on a Raspberry Pi!

Today we are going to look at how to install Docker and Portainer on a Raspberry Pi.

This process is very simple, but we will be using Portainer in future tutorials to setup different docker containers, so this will be the first thing we are going to look at. The Raspberry Pi 4 is pretty powerful for being as small as it is. Combine that with the fact that there are a ton of great docker containers that don’t require powerful CPU’s, running certain Docker containers on a Raspberry Pi becomes a great option for a lot of people.

The steps below will utilize a fresh install of the Raspberry Pi OS. If you aren’t sure how to do that, I have instructions here.

Required Hardware

Raspbery Pi 4: Docker and Portainer can be installed on older Raspberry Pi devices, but the Raspberry Pi 4 has more processing power than older devices which will lead to better performance.

Micro SD Card: Don’t need anything crazy here, just a good Micro SD card with enough storage space.

Raspberry Pi 4 Case: This is one of my favorite cases for the Raspberry Pi 4, but any case will do.

Power Supply: Needed to power your Raspberry Pi.

HDMI Cable: I generally SSH into my Raspberry Pi devices, so this is only required if you intend on connecting your Raspberry Pi to a display.

Instructions - Install Docker and Portainer on a Raspberry Pi

1. Ensure that your Raspberry Pi is up to date by running the commands below.

sudo apt update
sudo apt upgrade

2. The next thing we are going to run is the script to install Docker on our Raspberry Pi. Portainer is a GUI that manages Docker containers, so we need to ensure Docker is installed.

curl -sSL https://get.docker.com | sh

3. After the script completes, we need to give our Pi user account access to Docker.

sudo usermod -aG docker pi

4. After the user has been added, we are going to run a command to download the latest Portainer image for the ARM processor (which is what the Raspberry Pi uses).

sudo docker pull portainer/portainer-ce:linux-arm

5. Our final step is to create a new container that will run Portainer. If you are already using port 9000 on your Raspberry Pi for something else (this is unlikely), you will need to change the ports below.

sudo docker run --restart always -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:linux-arm

6. You should now be able to navigate to the IP address of your Raspberry Pi and port 9000 to access Portainer. When you get there, create a username and password.

http://[RASPBERRY_PI_IP_ADDRESS]:9000

portainer raspberry pi

7. Select Local and Connect.

portainer raspberry pi

8. You should now be connected to Portainer!

portainer raspberry pi

Conclusion

This is a pretty straight forward process, but we will be utilizing it in future tutorials. I decided it was best to create a specific tutorial for this rather than installing Docker/Portainer in all future tutorials. If you have any questions, please leave them in the comments. Stay tuned to see what containers we will be adding to our Raspberry Pi! Thanks for reading!

This Post Has 32 Comments

  1. Will Portainer work well on a Synology NAS?

    1. Portainer does work on a Synology NAS. I set it up a while ago but noticed that I wasn’t really using it so I removed it. If I get some time, I will look into some of the features it offers that the Synology Docker GUI doesn’t. Thanks for checking out the tutorial!

  2. i ran all commands successfully or so i thought. nothing happens when i pull up the ip address for portainer can you help?

    1. Did you receive any errors during the installation process? If not, are you willing to start from a fresh micro SD card to try again? It’s tough to troubleshoot since there aren’t that many commands, but if you received specific errors, we can look into those errors.

      Let me know and we will continue troubleshooting!

  3. Couple of things:-

    1) should you update your steps for portainer 2.0 / portainer-ce

    2) I get a dpkg error Code 1 at the end of The “ curl -sSL https://get.docker.com | sh” script

    1. Thanks for reading!

      1. I have been restraining from updating the the documentation to Portainer 2.0 because I’ve had a lot of problems with it on my Raspberry Pi. I don’t want to indirectly break any of the containers that people might have running, so until I can isolate what my issues are, I am holding off on updating the documentation.

      2. What error are you receiving?

      Let me know and we can continue troubleshooting!

      1. I also got the error Dan is describing and I think because of that when I try the command “sudo docker pull portainer/portainer:linux-arm” I get “Cannot connect to the Docker daemon at ect ect is the docker running?”

        1. That’s definitely a weird issue and I’m not entirely sure why it’s happening. It almost sounds like Docker isn’t running. Does Docker install properly? If it does, can you try and run this command and see if it works?

          service start docker

          Let me know and we can continue troubleshooting!

    2. Had the exact same problem, and it ended up being solved by updating my Raspberry Pi (3B+). “rpi-update”

      1. Worked for me, too! Thanks!

  4. Hi – Not able to “navigate to the IP address of your Raspberry Pi and port 9000 to access Portainer”.

    Using browser I get error
    “This site can’t provide a secure connection192.168.1.125 sent an invalid response.
    ERR_SSL_PROTOCOL_ERROR”.
    Solution was to use http:// rather than https://

    1. You are correct – I have a habit of typing https so I apologize for the mistake. I have updated the tutorial to reflect this. Thanks so much for the feedback!

  5. I have a Raspberry Pi4 (ARMv7) and follow your instruction but get an Waring/error. Do you have any ideas on how to fix this? See the copy from the terminal window below:NB: I want to use e.g. port 9100 since I use port 9000 for something else:

    [email protected]:~ $ sudo docker pull portainer/portainer:linux-arm
    linux-arm: Pulling from portainer/portainer
    Digest: sha256:9366dcbe948ad8ca977b0e31507a4b138837bb480ef78e9ee8bfe0101d4fcf63
    Status: Image is up to date for portainer/portainer:linux-arm
    docker.io/portainer/portainer:linux-arm

    [email protected]:~ $ sudo docker run –restart always -d -p 9100:9100 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer:linux-arm
    WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
    03737d9f6e7bf62a23d653880a6f0a40e82bc63d7be84cc46c66fb057ca86e63

    1. From what I’m searching, this is a “new” error for a lot of people running Docker on a Raspberry Pi. Are you running Docker 20.10 by any chance? I am thinking that downgrading might be the only temporary solution. Does everything work or it won’t continue the install?

      Let me know and we can continue troubleshooting!

      1. I had the same message. It still started and I could connect without problems.

  6. When trying to create the container to hold Portainer using the command above I get the following error

    WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested
    7ea9b314c564c8be6cd1f649e9537d30379a802595f3963ae01195d64d8ed6a8

    I’m using Docker Version: 20.10.1 Raspbian v10 (buster)

    1. From what I’m reading, this is a new issue caused by Docker 20.10. Does the container work properly? Or does it throw that error and then never start?

      Let me know and we can continue troubleshooting!

  7. The container seems to be working and it is Docker version 20.10.1. I tried the hello world and the this docker run -it ubuntu bash. See more info below:

    Client: Docker Engine – Community
    Version: 20.10.1
    API version: 1.41
    Go version: go1.13.15
    Git commit: 831ebea
    Built: Tue Dec 15 04:35:27 2020
    OS/Arch: linux/arm
    Context: default
    Experimental: true

    Server: Docker Engine – Community
    Engine:
    Version: 20.10.1
    API version: 1.41 (minimum version 1.12)
    Go version: go1.13.15
    Git commit: f001486
    Built: Tue Dec 15 04:33:02 2020
    OS/Arch: linux/arm
    Experimental: false
    containerd:
    Version: 1.4.3
    GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
    runc:
    Version: 1.0.0-rc92
    GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
    docker-init:
    Version: 0.19.0
    GitCommit: de40ad0

    [email protected]:~ $ sudo docker run hello-world
    Unable to find image ‘hello-world:latest’ locally
    latest: Pulling from library/hello-world
    4ee5c797bcd7: Pull complete
    Digest: sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec
    Status: Downloaded newer image for hello-world:latest

    Hello from Docker!
    This message shows that your installation appears to be working correctly.

    When i try to access Portainer in a browser, using http://192.168.86.9:9100/ it gives the message: This site can’t be reached 192.168.86.9 refused to connect.

    . . .and the IP is ok . . .
    [email protected]:~ $ ping 192.168.86.9
    PING 192.168.86.9 (192.168.86.9) 56(84) bytes of data.
    64 bytes from 192.168.86.9: icmp_seq=1 ttl=64 time=0.192 ms

    How do I downgrade, if you think that is the solution?

    1. That’s a great question. My Raspberry Pi is packed away right now (I’m in the process of moving), but you’re probably better off uninstalling Docker and reinstalling it using an older version.

      This thread should show you how to do it (I’m sorry that I can’t test it): https://forums.docker.com/t/how-can-i-install-a-specific-version-of-the-docker-engine/1993

      With that said, you also have the option of waiting a little while and running periodic updates to see if the issue is resolved in a newer version.

      Sorry for the somewhat empty response. I wish I could provide further details, but if there’s anything I can do to help, please let me know!

  8. Thanks for your help and the link. I will look into the details in the link.

  9. Hi,

    I have the same problem as Thomas, sadly I can’t seem to get around it. I have a fresh install using this guide and I chose to install a specific version of docker using the guide you posted in the latest comment. But I still get the same problem sadly.

    I have had any time to look into it?

    /Oscar H

  10. I figures it out, I didn’t get it to work with the first suggestion in the guide you linked to. I had to dig a bit deeper and find this guide: https://medium.com/@gauravsj9/how-to-install-specific-docker-version-on-linux-machine-d0ec2d4095

    Then I could install the latest available version of 19. These are the steps I used:

    I had to find the version to use:
    sudo apt-cache policy docker-ce

    and for me it was 5:19.03.14~3-0~raspbian-buster

    Then I could do:

    sudo apt-get install docker-ce=5:19.03.14~3-0~raspbian-buster

    Note: Remember to remove the old version you had. Instructions in this guide: https://medium.com/@gauravsj9/how-to-install-specific-docker-version-on-linux-machine-d0ec2d4095

    Then the rest of this guide worked perfectly!

    1. Awesome! Thanks so much for sharing the solution!

  11. depricated container.
    replace portainer/portainer with portainer/portainer-ce

    1. Funny you say that – I went in and updated that a little while ago because I am releasing a tutorial tomorrow that uses it! Thanks for the comment!

  12. Hi,

    when I try following these steps:

    curl -sSL https://get.docker.com | sh

    I’m receiving:
    [email protected]:~ $ curl -sSL https://get.docker.com | sh
    curl: (60) SSL certificate problem: unable to get local issuer certificate
    More details here: https://curl.haxx.se/docs/sslcerts.html

    curl failed to verify the legitimacy of the server and therefore could not
    establish a secure connection to it. To learn more about this situation and
    how to fix it, please visit the web page mentioned above.

    Any ideas how to install via a different route?

    Thanks

    1. I haven’t seen that error in specific, but it’s definitely a weird one. Are you running a DNS server or something else that’s checking your traffic and allowing/rejecting the connection?

      That page is just a script that runs certain commands to install Docker. You can view the script here: https://get.docker.com/

      Since you will most likely have to run the same commands, I’m not sure you’ll have much success using a different method. Are you using a fresh install of the Raspberry Pi OS?

  13. Thank you so much for keeping this up to date! Lovely tutorial!
    I just wanted to suggest adding this: “docker pull portainer/portainer-ce:linux-arm64”
    for those of us running 64 bit raspberry os

    1. Oh and when deploying the image, change this last bit:
      -v portainer_data:/data portainer/portainer-ce:linux-arm64 <-

      1. Great points, thanks so much! I will try and get this updated this weekend!

  14. Kept getting an error when trying to connect to the local instance saying “cannot connect to docker daemon” on the rpi 4 running the latest raspbian-buster-lite

    Used

    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

    thats listed on the portainer documentation instead and it worked like a charm.

    1. Thank you for sharing!

Leave a Reply

Close Menu