Files
prind/docker/klipper

Klipper packaged in Docker

What is Klipper?

Klipper is a 3d-Printer firmware. It combines the power of a general purpose computer with one or more micro-controllers. See the features document for more information on why you should use Klipper.

via https://www.klipper3d.org/

Usage

As Klipper is hardware dependent, there are considerations to make before deciding how to run the Container.

Standalone

If you intend to use Klipper in a Standalone configuration or with a GCODE-Sender that is dependent on a Serial connection (like Octoprint), it is necessary to start the container in privileged mode and allow access to /dev. Otherwise it would not be possible to use the emulated serial interface that is generated by klippy.
Point your GCODE-Sender to klipper.tty within the run directory.

Run

Create a configfile printer.cfg and a directory run and execute:

docker run \
  --privileged \
  -v /dev:/dev \
  -v $(pwd)/run:/opt/printer_data/run \
  -v $(pwd)/printer.cfg:/opt/printer_data/config/printer.cfg \
  mkuf/klipper:latest

Compose

services:
  klipper:
    image: mkuf/klipper:latest
    privileged: true
    volumes:
      - /dev:/dev
      - ./printer.cfg:/opt/printer_data/config/printer.cfg
      - ./run:/opt/printer_data/run

With Moonraker

If you intend to use Klipper together with Moonraker, both Containers can be started in unprivileged mode.
As communication between both services is handled via a unix socket, they need to share a common directory in which the socket may be located.
To limit klippers access to system devices (/dev), the printers physical serial port is linked into the container. In this example, the printers serial port is /dev/ttymc3.

Further Info on how to use the Moonraker Image can be found in its README.md

Create moonraker.conf and printer.cfg as well as the directories run and gcode, then run the containers.

Run

docker run \
  --device /dev/ttymxc3:/dev/ttymxc3 \
  -v $(pwd)/run:/opt/printer_data/run \
  -v $(pwd)/gcode:/opt/printer_data/gcodes \
  -v $(pwd)/printer.cfg:/opt/printer_data/config/printer.cfg \
  mkuf/klipper:latest

docker run \
  -v $(pwd)/run:/opt/printer_data/run \
  -v $(pwd)/gcode:/opt/printer_data/gcodes \
  -v $(pwd)/moonraker.conf:/opt/printer_data/config/moonraker.conf \
  -p 7125:7125 \
  mkuf/moonraker:latest

Compose

services:
  klipper:
    image: mkuf/klipper:latest
    devices:
      - /dev/ttymxc3:/dev/ttymxc3
    volumes:
      - ./printer.cfg:/opt/printer_data/config/printer.cfg
      - ./run:/opt/printer_data/run
      - ./gcode:/opt/printer_data/gcodes

  moonraker:
    image: mkuf/moonraker:latest
    ports:
      - "7125:7125"
    volumes:
      - ./moonraker.conf:/opt/printer_data/config/moonraker.conf
      - ./run:/opt/printer_data/run
      - ./gcode:/opt/printer_data/gcodes

Defaults

Entity Description
User klipper (1000:1000)
Workdir /opt
Entrypoint /opt/venv/bin/python klipper/klipper/klippy.py
Cmd -I printer_data/run/klipper.tty -a printer_data/run/klipper.sock printer_data/config/printer.cfg

Ports

none

Volumes

Volume Description
/opt/printer_data/run Default Location for runtime Files generated by Klipper.
Namely klipper.tty, the emulated Serial device
and klipper.sock, the unix socket that is used for communation with moonraker
/opt/printer_data/config Config directory to host printer.cfg
/opt/printer_data/gcodes Stores GCODE Files to be used by Klipper
/opt/printer_data/logs Log directory for Klipper and Moonraker

Tags

Tag Description Static
latest/nightly Refers to the most recent runtime Image. May point to a new build within 24h, depending on code changes in the upstream repository.
<7-digit-sha>
eg: d75154d
Refers to a specific commit SHA in the upstream repository. eg: Klipper3d/klipper:d75154d Yes
*-mcu Refers to a full blown Ubuntu Image containing all Tools necessary to Build the Microcontroller code for Klipper Yes

Targets

Target Description Pushed
build Pull Upstream Codebase and build python venv No
build-simulavr Based on mcu: Pull and Build simulavr for klipper. Used for testing without Hardware. No
run Default runtime Image Yes
mcu Build Tools for MCU code compilation Yes