🌐 VI | EN

Run OctoPrint in Docker with a USB printer device

Nghia Phan
Nghia Phan
🌐 Bản tiếng Việt → Technical Guide Views
Advertisement
Sponsored

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

Install Docker on Linux

Log into Linux and run:

# install prerequisitessudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y# add docker gpg keycurl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -# add docker software repositorysudo 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 dockersudo apt install docker-ce docker-compose containerd.io -y# enable and start docker servicesudo systemctl enable docker && sudo systemctl start docker# add the current user to the docker groupsudo usermod -aG docker $USER# reauthenticate for the new group membership to take effectsu - $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:
# create working directoriesmkdir ~/docker/octoprint -p# set owner of docker directorysudo chown "$USER":"$USER" ~/docker -R# allow the container to write to working directoriessudo chmod a+rwx -R ~/docker/octoprint# run the octoprint containerdocker 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
Quảng cáo

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

Footnotes

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

Sponsored Advertisement
Partnership

Comments & Discussion

Share your thoughts, ask questions and feedback

Markdown & QQ Emoji
Loading comments...