Installing docker, docker-compose on Raspberry Pi

Installed docker on raspberry pi 3b, OS version 11/bullseye. In the next post we will install pihole in docker.

Followed the link https://docs.docker.com/engine/install/raspberry-pi-os/

First we need to remove all unofficial packages, so type the following command. You may not have any packages installed, but let’s do it.

for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; doneCode language: JavaScript (javascript)

There are different methods to install docker, but we will use docker’s apt repository method .

Install using apt repository

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

1.Setup docker’s apt repository

    # Add Docker's official GPG key:
    sudo apt-get update
    sudo apt-get install ca-certificates curl
    sudo install -m 0755 -d /etc/apt/keyrings
    sudo curl -fsSL https://download.docker.com/linux/raspbian/gpg -o /etc/apt/keyrings/docker.asc
    sudo chmod a+r /etc/apt/keyrings/docker.asc
    
    # Add the repository to Apt sources:
    echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/raspbian \
      $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
      sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    sudo apt-get updateCode language: PHP (php)

    2. Install latest packages

    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginCode language: JavaScript (javascript)

    3. Verify that the installation is successful by running the hello-world image:

    sudo docker run hello-world

    Uninstall docker, docker-compose

    1. Uninstall 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-extrasCode language: JavaScript (javascript)

    2.Remove directories where images, volumes and containers are stored

    sudo rm -rf /var/lib/docker
    sudo rm -rf /var/lib/containerdCode language: JavaScript (javascript)

    3.Finally remove source keys and keyrings

    sudo rm /etc/apt/sources.list.d/docker.list
    sudo rm /etc/apt/keyrings/docker.ascCode language: PHP (php)

    Leave a Reply

    Your email address will not be published. Required fields are marked *