Bookmark

Run OctoPrint in Docker with a USB printer device

OctoPrint provides a web UI for controlling a 3D printer. This guide runs the container with data under ~/docker/octoprint, passes through /dev/ttyACM0, and exposes the web UI on port 8041.1

Youtube video player

The original i12bretro video is kept through the YouTube shortcode; it is not downloaded or rehosted.2

Install Docker on Linux

Log into Linux and run:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# install prerequisites
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
# add docker gpg key
curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
# add docker software repository
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
# install docker
sudo apt install docker-ce docker-compose containerd.io -y
# enable and start docker service
sudo systemctl enable docker && sudo systemctl start docker
# add the current user to the docker group
sudo usermod -aG docker $USER
# reauthenticate for the new group membership to take effect
su - $USER

Check the current Docker documentation if the distribution has removed apt-key.1

Run the OctoPrint container

  1. Create the directory, set ownership, and use the source serial mapping:
1
2
3
4
5
6
7
8
# create working directories
mkdir ~/docker/octoprint -p
# set owner of docker directory
sudo chown "$USER":"$USER" ~/docker -R
# allow the container to write to working directories
sudo chmod a+rwx -R ~/docker/octoprint
# run the octoprint container
docker run -d --name octoprint -v ~/docker/octoprint:/octoprint --device /dev/ttyACM0:/dev/ttyACM0 -p 8041:80 --restart=unless-stopped octoprint/octoprint

The real device may be /dev/ttyUSB0 or another name; do not change the command blindly. Confirm the host serial node first.1

  1. Open http://DNSorIP:8041.
  2. Click Next on the Start screen.
  3. Click Next on the Restore Backup screen.
  4. Create an account with a private username and password, then click Create Account.
  5. After creating the account, click Next.
  6. Enable or disable Connectivity Check, then click Next.
  7. Enable or disable Anonymous Usage Tracking, then click Next.
  8. Enable or disable Plugin Blacklist, then click Next.
  9. Click Next on the Webcam Wizard.
  10. Click Next on the Default Printer Profile.
  11. Click Next on Server Commands.
  12. Acknowledge the Finish screen messages and click Finish.
  13. Verify that OctoPrint appears and detects the printer.1

Safety checks

Check access to /dev/ttyACM0, docker logs octoprint, a test G-code upload, and the connection state before sending a real print. Do not expose an unauthenticated OctoPrint instance to the Internet; use a VPN or an authenticated reverse proxy.1

Source and video

Sources


  1. https://i12bretro.github.io/tutorials/0990.html — Run OctoPrint - 3D Printer Web UI - in Docker (i12bretro) ↩︎ ↩︎ ↩︎ ↩︎ ↩︎

  2. https://www.youtube.com/watch?v=Q0b6gNJlZ2g — Run OctoPrint - 3D Printer Web UI - in Docker (official video) ↩︎


0 Bình luận

Góp Ý / Bình Luận / Đánh giá