Skip to content

Instantly share code, notes, and snippets.

@M1XZG
Last active December 16, 2020 15:16
Show Gist options
  • Save M1XZG/3d513699baaf46f4da79eb2472b0517c to your computer and use it in GitHub Desktop.
Save M1XZG/3d513699baaf46f4da79eb2472b0517c to your computer and use it in GitHub Desktop.
Configure docker and portainer on a fresh PI4 build

Fresh docker install on PI4

Run the following after initial install of Raspberry OS

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install git zsh dnsutils logwatch logrotate postfix libsasl2-modules mailutils -y
sudo reboot

zsh is optional, but I really like using OhMyZSH.

Install docker (run as root)

sudo bash
curl -sSL https://get.docker.com | sh
usermod -aG docker pi 
apt install docker-compose

Note: replace pi in the above command if you've created another use you wish to log in as.

Install Portainer

docker volume create portainer_data
docker run --restart always -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock \
 --name Portainer -v portainer_data:/data portainer/portainer-ce

Connect to http://<pi address>:9000

Install docker-ctop

echo "deb http://packages.azlux.fr/debian/ buster main" | sudo tee /etc/apt/sources.list.d/azlux.list
wget -qO - https://azlux.fr/repo.gpg.key | sudo apt-key add -
sudo apt update
sudo apt install docker-ctop

Run ctop to use

Octoprint in docker

Taken from the octoprint/octoprint page on Docker Hub

A couple of things to potentially change below, make sure /dev/ttyUSB0 and /dev/video0 match your printer and webcam ports, also adjust the webcam resolution to match yours.

docker volume create octoprint

docker run -d 
    -v octoprint:/octoprint \
    -v /dev:/dev 
    --device /dev/ttyUSB0:/dev/ttyUSB0 \
    --device /dev/video0:/dev/video0 \
    -e MJPG_STREAMER_INPUT="-y -n -r 1280x720" \
    -e ENABLE_MJPG_STREAMER=true -p 80:80 \
    --restart unless-stopped 
    --name Octoprint 
    octoprint/octoprint

Connect to http://<pi address>/

If you are upgrading from a standalone octoprint to docker, make sure your octoprint is running the latest version of Octoprint, take a backup and download this backup file. Once you fire up the docker install for the first time use the restore option, upload your backup file and wait until it's complete. This worked perfectly for me going from a Octoprint 1.5 -> Docker Octoprint 1.5. This is did not work when my standalone octoprint was on 1.4.x.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment