Setup multiple Octoprint instances in Docker on Debian 10

Hello everyone, a quick and dirty guide to setup multiple Octoprint sessions using Docker in Debian 10. I can run 12 sessions on a HP Z200 i3 workstation with 4GB ram with ease. You can usually find i5 HP Z200 on ebay for $50-80 and this is by far more preferable than a Raspberry Pi for running multiple printers.

Installing Docker on Debian:

  1. Install prerequisites
    • sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  2. Add Docker repo key
    • curl -fsSL | sudo apt-key add -
  3. Add repo
    • sudo add-apt-repository "deb [arch=amd64] Index of linux/debian/ $(lsb_release -cs) stable"
    • Linux Mint Debian Edition needed instead
    sudo add-apt-repository "deb [arch=amd64] Index of linux/debian/ buster stable"
  4. Install relevant Docker packages
    • sudo apt-get install docker-ce docker-ce-cli docker-compose
  5. Pull Octoprint from Docker repo
    • sudo docker pull octoprint/octoprint
  6. Test Docker
    • sudo docker run hello-world

Configure UDEV for static USB naming for each printer:

  1. Disconnect all printers from your print server except for 1 device
  2. Type ls /dev/serial/by-path/ copy the path of your printer excluding the “-port0”
    • should be like pci-0000:00:1a.0-usb-0:1.6:1.0
  3. Create new UDEV rule. UDEV rule MUST begin with a letter or it will prematurely enumerate.
    • sudo nano /etc/udev/rules.d/a-usb.rules
  4. Create a rule for each printer
    • SUBSYSTEM=="tty", ENV{ID_PATH}=="pci-0000:00:1a.0-usb-0:1.4:1.0", SYMLINK+="ender3-0"
    • enter path for each printer
    • make sure each name is unique for each printer like “ender3-0” and “ender3-1” etc
  5. Add each printer one by one and type
    • ls /dev/serial/by-path/
    • create a UDEV rule for each printer
  6. After adding all your UDEV entries save and reboot
    • you can also use sudo udevadm trigger to have UDEV reload your rules rather than rebooting.

Further reading:

Configure Docker containers:

  1. create working directory
    • i.e. mkdir /apps/octoprint -p
  2. change into directory
    • cd /apps/octoprint/
  3. create docker-compose file
    • sudo nano docker-compose.yml
  4. create entries for each printer/octoprint container
    • change all the @ to match your needs, like name and port numbers need to be unique for each. like port 3001, 3002 etc, and names ender3-0, ender3-1. etc
version: '2.2'

    restart: unless-stopped
    image: octoprint/octoprint
    container_name: octoprint-ender3-@
      - 300@:5000
      - /dev/ender3-@:/dev/ttyACM0
     - /apps/octoprint/ender3-@:/home/octoprint
    restart: unless-stopped
    image: octoprint/octoprint
    container_name: octoprint-ender3-@
      - 300@:5000
      - /dev/ender3-@:/dev/ttyACM0
     - /apps/octoprint/ender3-@:/home/octoprint

  1. save the file
  2. create containers
    • sudo docker-compose up -d

Final notes:
• if the printers are not connected when Debian boots, then that particular Octoprint container will not load. You need to reboot Debian for UDEV to create the Symlinks so that the Octoprint containers will start with whatever printers are connected. You can boot Debian with all printers attached, then unplug them if you don't need them powered up.
• It is possible to leave unused printers powered off with USBs unplugged and
plug them in as necessary by using sudo udevadm trigger and docker start octoprint-ender3-7 to start the docker for the printer desired without needing to reboot.
• I would appreciate if someone could help me add webcam to this guide!


Awesome thanks a lot! it works great! I set up a github ( page with an example docker-compose file and basic instructions on how I got the camera working by running mjpg_streamer on the host (not an elegant solution but it works...)

1 Like