Run OctoPrint in Docker with a USB printer device
Nghia Phan
Table of Contents
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
- 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
- Open
http://DNSorIP:8041. - Click Next on the Start screen.
- Click Next on the Restore Backup screen.
- Create an account with a private username and password, then click Create Account.
- After creating the account, click Next.
- Enable or disable Connectivity Check, then click Next.
- Enable or disable Anonymous Usage Tracking, then click Next.
- Enable or disable Plugin Blacklist, then click Next.
- Click Next on the Webcam Wizard.
- Click Next on the Default Printer Profile.
- Click Next on Server Commands.
- Acknowledge the Finish screen messages and click Finish.
- 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
- Original tutorial: i12bretro 0990
- Original video: Run OctoPrint - 3D Printer Web UI - in Docker
Comments & Discussion
Share your thoughts, ask questions and feedback