# How to self-host Gotenberg with Docker Self-host Gotenberg with Docker in five minutes, lock it down for production, and learn when a hosted HTML-to-PDF API is the better deal. [Gotenberg](https://gotenberg.dev) is an open-source (MIT) Docker image that wraps headless Chromium and LibreOffice behind a simple HTTP API. html-pdf.com runs it under the hood, so everything below comes from running it in production. **Quick answer.** Start the container with `docker run --rm -p 3000:3000 gotenberg/gotenberg:8`, then post an `index.html` file to `/forms/chromium/convert/html`. If you would rather not run a server, the hosted API takes JSON and returns a PDF: ```bash curl https://html-pdf.com/v1/pdf -H "Authorization: Bearer $HTML_PDF_KEY" \ -d '{"html": "

Hello

"}' -o out.pdf ``` ## 1. Start Gotenberg This step gets a local Gotenberg server running with one command. ```bash docker run --rm -p 3000:3000 gotenberg/gotenberg:8 ``` Check that it is up. ```bash curl http://localhost:3000/health ``` ## 2. Convert HTML to PDF Here you turn an HTML file or a live URL into a PDF. Gotenberg expects a `multipart/form-data` request with a file named exactly `index.html`. ```bash echo '

Hello from Gotenberg

' > index.html curl -F files=@index.html http://localhost:3000/forms/chromium/convert/html -o out.pdf ``` Useful form fields include `paperWidth` / `paperHeight` (inches or units like `210mm`), `marginTop`…`marginLeft`, `landscape=true`, `printBackground=true` and `waitDelay=2s`. You can send images, fonts and CSS as extra `files` and reference them by name from `index.html`. To render a live web page instead, use the URL route. ```bash curl -F url=https://example.com http://localhost:3000/forms/chromium/convert/url -o page.pdf ``` ## 3. Lock it down before exposing it These settings keep a public Gotenberg from becoming a security hole. By default it renders anything for anyone who can reach it, so fix that before it touches the internet. - **Don't publish the port.** Keep it on a private Docker network and call it only from your app. - **Add basic auth** if it must be reachable remotely. ```bash docker run -p 3000:3000 \ -e GOTENBERG_API_BASIC_AUTH_USERNAME=me -e GOTENBERG_API_BASIC_AUTH_PASSWORD=long-random-secret \ gotenberg/gotenberg:8 gotenberg --api-enable-basic-auth ``` - **Block SSRF.** HTML from users can point `` or `