Install Docker Engine on Raspberry Pi OS (2023)

To get started with Docker Engine on Raspberry Pi OS, make sure youmeet the prerequisites, and then follow theinstallation steps.

Prerequisites

Note

If you use ufw or firewalld to manage firewall settings, be aware thatwhen you expose container ports using Docker, these ports bypass yourfirewall rules. For more information, refer toDocker and ufw.

OS requirements

To install Docker Engine, you need the 64-bit version or 32-bit version of one of these Raspberry Pi OSversions:

  • Raspberry Pi OS Bookworm 12 (testing)
  • Raspberry Pi OS Bullseye 11 (stable)
  • Raspberry Pi OS Buster 10 (oldstable)

Docker Engine for Raspberry Pi OS is compatible with the armhf architecture.

For the 64-bit version of Raspberry Pi OS follow the instructions for Debian.

Uninstall old versions

Before you can install Docker Engine, you must first make sure that anyconflicting packages are uninstalled.

Distro maintainers provide an unofficial distributions of Docker packages inAPT. You must uninstall these packages before you can install the officialversion of Docker Engine.

The unofficial packages to uninstall are:

  • docker.io
  • docker-compose
  • docker-doc
  • podman-docker

Moreover, Docker Engine depends on containerd and runc. Docker Enginebundles these dependencies as one bundle: containerd.io. If you haveinstalled the containerd or runc previously, uninstall them to avoidconflicts with the versions bundled with Docker Engine.

Run the following command to uninstall all conflicting packages:

$ for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done

apt-get might report that you have none of these packages installed.

Images, containers, volumes, and networks stored in /var/lib/docker/ aren’tautomatically removed when you uninstall Docker. If you want to start with aclean installation, and prefer to clean up any existing data, read theuninstall Docker Engine section.

Installation methods

You can install Docker Engine in different ways, depending on your needs:

  • Docker Engine comes bundled withDocker Desktop for Linux. This isthe easiest and quickest way to get started.

  • Set up and install Docker Engine fromDocker’s apt repository.

  • Install it manually and manage upgrades manually.

    (Video) How To Install Docker on Raspberry Pi 4 - Run Docker Container on Raspberry Pi

  • Use a convenience scripts. Onlyrecommended for testing and development environments.

Install using the apt repository

Before you install Docker Engine for the first time on a new host machine, youneed to set up the Docker repository. Afterward, you can install and updateDocker from the repository.

Set up the repository

  1. Update the apt package index and install packages to allow apt to use arepository over HTTPS:

  2. Add Docker’s official GPG key:

    $ sudo install -m 0755 -d /etc/apt/keyrings$ curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg$ sudo chmod a+r /etc/apt/keyrings/docker.gpg
  3. Use the following command to set up the repository:

    $ echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/raspbian \ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  4. Update the apt package index:

    $ sudo apt-get update

Install Docker Engine

  1. Install Docker Engine, containerd, and Docker Compose.


    To install the latest version, run:

     $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    (Video) How to install Docker (and Portainer) on a RaspberryPi and run millions of apps on your RaspberryPi!

    To install a specific version of Docker Engine, start by listing the availableversions in the repository:

    # List the available versions:$ apt-cache madison docker-ce | awk '{ print $3 }'5:24.0.0-1~raspbian.11~bullseye5:23.0.6-1~raspbian.11~bullseye<...>

    Select the desired version and install:

    $ VERSION_STRING=5:24.0.0-1~raspbian.11~bullseye$ sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
  2. Verify that the Docker Engine installation is successful by running thehello-world image:

    $ sudo docker run hello-world

    This command downloads a test image and runs it in a container. When thecontainer runs, it prints a confirmation message and exits.

You have now successfully installed and started Docker Engine.

Tip

Receiving errors when trying to run without root?

The docker user group exists but contains no users, which is why you’re required to use sudo to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.

Upgrade Docker Engine

To upgrade Docker Engine, follow theinstallation instructions, choosing the new versionyou want to install.

Install from a package

If you can’t use Docker’s apt repository to install Docker Engine, you candownload the deb file for your release and install it manually. You need todownload a new file each time you want to upgrade Docker Engine.

  1. Go to https://download.docker.com/linux/raspbian/dists/.

    (Video) Install Docker On Raspberry Pi 4

  2. Select your Raspberry Pi OS version in the list.

  3. Go to pool/stable/ and select the applicable architecture (amd64,armhf, arm64, or s390x).

  4. Download the following deb files for the Docker Engine, CLI, containerd,and Docker Compose packages:

    • containerd.io_<version>_<arch>.deb
    • docker-ce_<version>_<arch>.deb
    • docker-ce-cli_<version>_<arch>.deb
    • docker-buildx-plugin_<version>_<arch>.deb
    • docker-compose-plugin_<version>_<arch>.deb
  5. Install the .deb packages. Update the paths in the following example towhere you downloaded the Docker packages.

    $ sudo dpkg -i ./containerd.io_<version>_<arch>.deb \ ./docker-ce_<version>_<arch>.deb \ ./docker-ce-cli_<version>_<arch>.deb \ ./docker-buildx-plugin_<version>_<arch>.deb \ ./docker-compose-plugin_<version>_<arch>.deb

    The Docker daemon starts automatically.

  6. Verify that the Docker Engine installation is successful by running thehello-world image:

    $ sudo service docker start$ sudo docker run hello-world

    This command downloads a test image and runs it in a container. When thecontainer runs, it prints a confirmation message and exits.

You have now successfully installed and started Docker Engine.

Tip

Receiving errors when trying to run without root?

The docker user group exists but contains no users, which is why you’re required to use sudo to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.

Upgrade Docker Engine

To upgrade Docker Engine, download the newer package files and repeat theinstallation procedure, pointing to the new files.

Install using the convenience script

Docker provides a convenience script athttps://get.docker.com/ to install Docker intodevelopment environments non-interactively. The convenience script isn’trecommended for production environments, but it’s useful for creating aprovisioning script tailored to your needs. Also refer to theinstall using the repository steps to learnabout installation steps to install using the package repository. The source codefor the script is open source, and you can find it in thedocker-install repository on GitHub.

Always examine scripts downloaded from the internet before running them locally.Before installing, make yourself familiar with potential risks and limitationsof the convenience script:

  • The script requires root or sudo privileges to run.
  • The script attempts to detect your Linux distribution and version andconfigure your package management system for you.
  • The script doesn’t allow you to customize most installation parameters.
  • The script installs dependencies and recommendations without asking forconfirmation. This may install a large number of packages, depending on thecurrent configuration of your host machine.
  • By default, the script installs the latest stable release of Docker,containerd, and runc. When using this script to provision a machine, this mayresult in unexpected major version upgrades of Docker. Always test upgrades ina test environment before deploying to your production systems.
  • The script isn’t designed to upgrade an existing Docker installation. Whenusing the script to update an existing installation, dependencies may not beupdated to the expected version, resulting in outdated versions.

Tip: preview script steps before running

(Video) Raspberry Pi 4 - How To Install Docker On Raspberry Pi

You can run the script with the --dry-run option to learn what steps thescript will run when invoked:

$ curl -fsSL https://get.docker.com -o get-docker.sh$ sudo sh ./get-docker.sh --dry-run

This example downloads the script fromhttps://get.docker.com/ and runs it to install thelatest stable release of Docker on Linux:

$ curl -fsSL https://get.docker.com -o get-docker.sh$ sudo sh get-docker.shExecuting docker install script, commit: 7cae5f8b0decc17d6571f9f52eb840fbc13b2737<...>

You have now successfully installed and started Docker Engine. The dockerservice starts automatically on Debian based distributions. On RPM baseddistributions, such as CentOS, Fedora, RHEL or SLES, you need to start itmanually using the appropriate systemctl or service command. As the messageindicates, non-root users can’t run Docker commands by default.

Use Docker as a non-privileged user, or install in rootless mode?

The installation script requires root or sudo privileges to install anduse Docker. If you want to grant non-root users access to Docker, refer to thepost-installation steps for Linux.You can also install Docker without root privileges, or configured to run inrootless mode. For instructions on running Docker in rootless mode, refer torun the Docker daemon as a non-root user (rootless mode).

Install pre-releases

Docker also provides a convenience script athttps://test.docker.com/ to install pre-releases ofDocker on Linux. This script is equal to the script at get.docker.com, butconfigures your package manager to use the test channel of the Docker packagerepository. The test channel includes both stable and pre-releases (betaversions, release-candidates) of Docker. Use this script to get early access tonew releases, and to evaluate them in a testing environment before they’rereleased as stable.

To install the latest version of Docker on Linux from the test channel, run:

$ curl -fsSL https://test.docker.com -o test-docker.sh$ sudo sh test-docker.sh

Upgrade Docker after using the convenience script

If you installed Docker using the convenience script, you should upgrade Dockerusing your package manager directly. There’s no advantage to re-running theconvenience script. Re-running it can cause issues if it attempts to re-installrepositories which already exist on the host machine.

Uninstall Docker Engine

  1. Uninstall the Docker Engine, CLI, containerd, and Docker Compose packages:

    $ sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
  2. Images, containers, volumes, or custom configuration files on your hostaren’t automatically removed. To delete all images, containers, and volumes:

    $ sudo rm -rf /var/lib/docker$ sudo rm -rf /var/lib/containerd
    (Video) Setting Up Your First Raspberry Pi 4 Docker Server with CasaOS - Episode 1

You have to delete any edited configuration files manually.

Next steps

  • Continue to Post-installation steps for Linux.
  • Review the topics in Develop with Docker to learnhow to build new applications using Docker.

FAQs

Install Docker Engine on Raspberry Pi OS? ›

In the best case scenario, Docker can be installed with Raspberry Pi's operating system. The Docker team has provided a special installation script for this. The first step involves downloading and executing the script, which you can do using a cURL command.

How to install Docker engine on Raspberry Pi? ›

Install from a package
  1. Select your Raspberry Pi OS version in the list.
  2. Go to pool/stable/ and select the applicable architecture ( amd64 , armhf , arm64 , or s390x ).
  3. Download the following deb files for the Docker Engine, CLI, containerd, and Docker Compose packages: ...
  4. Install the .deb packages.

Can you run Docker on Raspberry Pi OS? ›

In the best case scenario, Docker can be installed with Raspberry Pi's operating system. The Docker team has provided a special installation script for this. The first step involves downloading and executing the script, which you can do using a cURL command.

How to install Docker Engine on Linux? ›

Install Docker Engine
  1. Install Docker Engine, containerd, and Docker Compose. Latest. Specific version. To install the latest version, run: ...
  2. Verify that the Docker Engine installation is successful by running the hello-world image. $ sudo docker run hello-world. This command downloads a test image and runs it in a container.

Can you run Docker on Raspberry Pi 4? ›

To begin using Docker on your Raspberry Pi 4, you must first install it as follows: 1. Open a terminal, and run the below apt update command to ensure your Pi is up to date with the most recent improvements, bug fixes, and security updates.

How to install Docker Engine without Docker Desktop? ›

How to use Docker on Windows 10 (without Docker Desktop)
  1. Check if you have WSL 2 enabled on your system. ...
  2. Install Ubuntu from Microsoft Store. ...
  3. Create user. ...
  4. Enable Internet connection. ...
  5. Run sudo apt update.
  6. Install Docker. ...
  7. Add sudo to Docker. ...
  8. Add your user to docker group so you can run Docker as a non-root user.

Is Docker worth it on Raspberry Pi? ›

Since Docker has been used successfully for many scenarios on Linux, using it with Raspberry Pi shouldn't be a problem. However, the differences in the hardware can indeed lead to some problems, as Pi is not just a no-frills version of a PC but uses an entirely different processor architecture.

What is the best OS for Docker production? ›

Any Linux OS can be used for docker but we prefer Boot2Docker or RancherOS. There are many reasons why you would want to choose one over the other. Boot2Docker is a better choice for Windows and Mac OS X users because it provides an easy way to get started with Docker.

Which OS can run Docker? ›

The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.

Which Linux OS can run Docker? ›

There are various options for operating systems that work well for Docker.
  • RancherOS. RancherOS is a compatible fit for Docker deployments because it is an operating system made from Docker containers. ...
  • Ubuntu Core. ...
  • Alpine Linux. ...
  • Mesosphere DC/OS.
Jul 11, 2023

What is the difference between Docker desktop and Docker engine? ›

Docker containers are running inside the virtual machine. Everything else is a consequence. Docker Desktop just tries to hide that fact from you so you don't need to setup a virtual machine and the client-server connection. Having a virtual machine is required on Windows and MacOS if you want to run Linux containers.

How to start Docker engine on Linux? ›

Note
  1. Create the docker group. $ sudo groupadd docker.
  2. Add your user to the docker group. $ sudo usermod -aG docker $USER.
  3. Log out and log back in so that your group membership is re-evaluated. ...
  4. Verify that you can run docker commands without sudo .

Is Docker Engine free for Linux? ›

*Docker Desktop is free to use as part of the Docker Personal subscription for individuals, non-commercial open source developers, students and educators, and small businesses of fewer than than 250 employees AND less than $10 million in revenue.

Can Docker image run on any OS? ›

Docker image containers can also run natively on Linux and Windows. However, Windows images can run only on Windows hosts and Linux images can run on Linux hosts and Windows hosts (using a Hyper-V Linux VM, so far), where host means a server or a VM.

What systems can Raspberry Pi 4 emulate well? ›

A Pi 4's extra performance gets you a few benefits compared to an old Pi 3 or 3B+, including more consistent (but not universally problem-free) emulation speed for the Nintendo 64, Sega Dreamcast, and Sony PSP and the ability to turn on some lag-reducing features that we'll talk about in a bit.

How many Docker containers can Raspberry Pi 4 run? ›

As Docker containers are lightweight, you can easily fit it 5-10 or more Docker containers on a Raspberry Pi host.

How do I start a Docker engine? ›

If you've installed Docker Desktop and want to explore more, here's a quick example to get you started:
  1. Open Docker Desktop.
  2. Type the following command in your terminal: docker run -d -p 80:80 docker/getting-started.
  3. Follow the instructions for either Mac or Windows to access your dashboard.
Mar 31, 2022

How to install Docker Compose on Raspberry Pi 4? ›

Steps to Install Docker Compose on Raspberry Pi;
  1. Set up your Raspberry Pi Operating System (OS)
  2. Upgrade Packages.
  3. Install Docker.
  4. Install Docker-Compose.
  5. Enable the Docker system service to start your containers on boot.
Aug 18, 2021

How to install Docker engine using Ansible? ›

Running this playbook will perform the following actions on your Ansible hosts:
  1. Install aptitude , which is preferred by Ansible as an alternative to the apt package manager.
  2. Install the required system packages.
  3. Install the Docker GPG APT key.
  4. Add the official Docker repository to the apt sources.
  5. Install Docker.
Mar 1, 2022

Videos

1. Raspberry Pi: Docker & Portainer Setup! (Tutorial)
(WunderTech)
2. How to install Docker and Docker Compose on Raspberry Pi?
(Bobby Iliev)
3. raspberry pi 4 docker install | install docker on raspberry pi 4
(FREEDOM TECH)
4. How to install Docker on Raspberry Pi | All models
(PcMac)
5. you need to learn Docker RIGHT NOW!! // Docker Containers 101
(NetworkChuck)
6. How to install Docker Engine on Ubuntu + Setup Pi-Hole DNS Ad Blocker on a container
(ElastiCourse)
Top Articles
Latest Posts
Article information

Author: Ray Christiansen

Last Updated: 04/09/2023

Views: 6523

Rating: 4.9 / 5 (49 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.