2023-06-11 16:09:07 +02:00
|
|
|
---
|
|
|
|
title: "How to install Docker and Portainer"
|
|
|
|
date: 2023-06-11T13:06:44+02:00
|
2023-06-11 16:09:58 +02:00
|
|
|
draft: false
|
2023-06-11 16:09:07 +02:00
|
|
|
author: "Mathieu Broillet"
|
|
|
|
cover : "img/docker.png"
|
|
|
|
# coverAlt : "alt image"
|
|
|
|
# coverCaption : "credit of image"
|
|
|
|
description : "How to install Docker, Portainer and the Portainer agent"
|
|
|
|
tags : ['docker', 'portainer', 'podman']
|
|
|
|
---
|
|
|
|
|
|
|
|
# Introduction
|
|
|
|
|
|
|
|
To install Docker, you can follow the steps outlined in the [official](https://docs.docker.com/engine/install/) Docker installation documentation.
|
|
|
|
|
|
|
|
# Installation
|
|
|
|
## Docker
|
|
|
|
### Debian
|
|
|
|
If you're using Debian, you can use the following commands:
|
|
|
|
{{< code language="BASH" title="Debian" expand="Show" collapse="Hide" isCollapsed="false" >}}
|
|
|
|
sudo apt-get remove docker docker-engine docker.io containerd runc -y
|
|
|
|
sudo apt-get update -y
|
|
|
|
sudo apt-get install \
|
|
|
|
ca-certificates \
|
|
|
|
curl \
|
|
|
|
gnupg -y
|
|
|
|
sudo install -m 0755 -d /etc/apt/keyrings
|
|
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
|
|
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
|
|
|
echo \
|
|
|
|
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
|
|
|
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
|
|
|
|
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
|
|
sudo apt-get update -y
|
|
|
|
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
|
|
|
{{< /code >}}
|
|
|
|
|
|
|
|
|
|
|
|
### Ubuntu
|
|
|
|
If you're using Ubuntu, you can use the following commands:
|
|
|
|
|
|
|
|
{{< code language="BASH" title="Ubuntu" expand="Show" collapse="Hide" isCollapsed="false" >}}
|
|
|
|
sudo apt-get remove docker docker-engine docker.io containerd runc -y
|
|
|
|
sudo apt-get update -y
|
|
|
|
sudo apt-get install ca-certificates curl gnupg -y
|
|
|
|
sudo install -m 0755 -d /etc/apt/keyrings
|
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
|
|
sudo chmod a+r /etc/apt/keyrings/docker.gpg
|
|
|
|
echo \
|
|
|
|
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
|
|
|
|
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
|
|
|
|
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
|
|
sudo apt-get update -y
|
|
|
|
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
|
|
|
{{< /code >}}
|
|
|
|
|
|
|
|
## Portainer
|
|
|
|
|
|
|
|
Here are the commands to install Portainer and upgrade the Portainer container:
|
|
|
|
|
|
|
|
{{< code language="BASH" title="Installation" expand="Show" collapse="Hide" isCollapsed="false" >}}
|
|
|
|
docker run -d -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
|
|
|
|
{{< /code >}}
|
|
|
|
|
|
|
|
{{< code language="BASH" title="Upgrade" expand="Show" collapse="Hide" isCollapsed="false" >}}
|
|
|
|
docker stop portainer
|
|
|
|
docker rm portainer
|
|
|
|
docker image rm portainer/portainer-ce:latest
|
|
|
|
docker run -d -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
|
|
|
|
{{< /code >}}
|
|
|
|
|
|
|
|
### Agent
|
|
|
|
|
|
|
|
{{< code language="BASH" title="Installation" expand="Show" collapse="Hide" isCollapsed="false" >}}
|
|
|
|
docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent
|
|
|
|
{{< /code >}}
|
|
|
|
|
|
|
|
{{< code language="BASH" title="Re-installation" expand="Show" collapse="Hide" isCollapsed="false" >}}
|
|
|
|
docker stop portainer_agent
|
|
|
|
docker rm portainer_agent
|
|
|
|
docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent
|
|
|
|
{{< /code >}}
|
|
|
|
|
|
|
|
{{< code language="BASH" title="Installation on Podman" expand="Show" collapse="Hide" isCollapsed="false" >}}
|
|
|
|
systemctl enable --now podman.socket
|
|
|
|
mkdir -p /var/lib/containers/storage/volumes
|
|
|
|
|
|
|
|
podman run -d --privileged \
|
|
|
|
-p 9001:9001 \
|
|
|
|
--name portainer_agent \
|
|
|
|
--restart=always \
|
|
|
|
-v /run/podman/podman.sock:/var/run/docker.sock:Z \
|
|
|
|
-v /var/lib/containers/storage/volumes:/var/lib/docker/volumes \
|
|
|
|
portainer/agent
|
|
|
|
{{< /code >}}
|