🌐 VI • EN
Run OctoPrint in Docker with a USB printer device
TABLE OF CONTENTS (Nhấn để xem)
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 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
- Create the directory, set ownership, and use the source serial mapping:
# 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
- 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
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
Discussion & Feedback 0
Share your questions, feedback or insights with the community