Gotenberg is an open-source API-based document conversion and generation service designed primarily for converting HTML, Markdown, and various document formats into PDF files. It is written in Go and provides a lightweight and scalable alternative to traditional document processing solutions.
This tutorial explains how to install Gotenberg inside a Docker container on Linux. Commands have been tested on Ubuntu.
Prepare environment
Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.
Install Gotenberg
- Host network
Run the following command to create a container for Gotenberg that uses host network:
docker run -d --name=gotenberg --restart=always --network=host \
gotenberg/gotenberg
- User-defined bridge network
User-defined bridge network can be used for listening on different port. By default, Gotenberg service is listening on port 3000. It can be changed with -p
option.
docker network create app-net
docker run -d --name=gotenberg --restart=always --network=app-net \
-p 8080:3000 \
gotenberg/gotenberg
Testing Gotenberg
Gotenberg provides various API endpoints and parameters for converting documents. For instance, the following command sends a request to Gotenberg service to convert a webpage into a PDF file:
curl -o test.pdf -X POST -F "url=https://sparksuite.github.io/simple-html-invoice-template" \
http://<IP_ADDRESS>:3000/forms/chromium/convert/url
Note: Replace <IP_ADDRESS>
with the system's actual IP address.
Uninstall Gotenberg
To completely remove Gotenberg, remove its container:
docker rm --force gotenberg
Remove Gotenberg image:
docker rmi gotenberg/gotenberg
If a user-defined bridge network was created, you can delete it as follows:
docker network rm app-net
Leave a Comment
Cancel reply