Menu

1 / 2

How to deploy a Go app with Docker using a tiny image

DEV Community: docker·octave Nkurunziza·12 days ago
#utouH8rA
#devtodocker#devto#dev#build#docker
Reading 0:00
15s threshold

You wrote a small Go web service and now you want it online. Go makes this easier than almost any other language: it compiles to one file that needs nothing else to run. So your Docker image doesn't need an operating system, a package manager or a shell, only your binary. This guide shows how to deploy a Go app with Docker: build that tiny image with a two-stage Dockerfile, put it online with an HTTPS address, and avoid the seven errors that break most first attempts.

Try it on Hubfly space →

What you'll build

A Go HTTP server with a /healthz endpoint, a built-in health check command and graceful shutdown.

A two-stage Dockerfile: stage 1 compiles with the full Go toolchain, stage 2 copies only the binary into a distroless image that runs as a non-root user.

A live deployment on Hubfly space with an HTTPS address.

The compiled server is about 6 MB . While idle, the Metrics tab shows about 1 MB of memory .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.