{"id":328,"date":"2026-05-04T09:00:00","date_gmt":"2026-05-04T03:30:00","guid":{"rendered":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/"},"modified":"2026-10-10T21:21:04","modified_gmt":"2026-10-10T15:51:04","slug":"go-docker-deployment","status":"publish","type":"post","link":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/","title":{"rendered":"Go Docker Deployment: Build Tiny Container Images"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Go Docker deployment packs your compiled program into a small container image that runs the same way on every server. In this post, you will build a static binary and write a multi-stage Dockerfile. Then you will run the result in an image of only about 8 MB.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This lesson builds directly on <a href=\"https:\/\/smitabharat.com\/blog\/go-cross-compilation-build\/\">Go cross compilation for any OS<\/a>, because a container needs a Linux binary. Our example app also reads its port from the environment, just like in <a href=\"https:\/\/smitabharat.com\/blog\/go-environment-variables-config\/\">Go environment variables for configuration<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Is Go Docker Deployment?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First, a container is a lightweight box that holds your program and everything it needs to run. Then Docker builds that box from a recipe file called a <code>Dockerfile<\/code>. As a result, the app runs the same on your laptop, a test server and the cloud.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, think of a lunch box. You pack the meal once at home, and then it travels anywhere unchanged. Similarly, Go Docker deployment packs one binary and ships it to any machine with Docker.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Above all, Go is a great fit for containers. In fact, a Go program compiles into a single file with no runtime to install. So the image can stay tiny.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Example App for Go Docker Deployment<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net\/http\"\n\t\"os\"\n)\n\nfunc main() {\n\tport := os.Getenv(\"PORT\")\n\tif port == \"\" {\n\t\tport = \"8080\"\n\t}\n\n\thttp.HandleFunc(\"GET \/hello\", func(w http.ResponseWriter, r *http.Request) {\n\t\tfmt.Fprintln(w, \"Hello from a container!\")\n\t})\n\thttp.HandleFunc(\"GET \/health\", func(w http.ResponseWriter, r *http.Request) {\n\t\tfmt.Fprintln(w, \"ok\")\n\t})\n\n\tlog.Printf(\"listening on :%s\", port)\n\tlog.Fatal(http.ListenAndServe(\":\"+port, nil))\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In fact, this small server is enough to show the whole process. Also, the <code>\/health<\/code> route gives Docker and cloud platforms an easy way to check that the app is alive. Earlier, you built a bigger version in <a href=\"https:\/\/smitabharat.com\/blog\/go-http-server-beginners\/\">the Go HTTP server tutorial<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Multi-Stage Dockerfile for Go Docker Deployment<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># Stage 1: build the binary\nFROM golang:1.24-alpine AS build\nWORKDIR \/src\nCOPY go.mod go.sum* .\/\nRUN go mod download\nCOPY . .\nRUN CGO_ENABLED=0 GOOS=linux go build -ldflags=\"-s -w\" -o \/app .\n\n# Stage 2: run it in an empty image\nFROM scratch\nCOPY --from=build \/app \/app\nEXPOSE 8080\nUSER 65534:65534\nENTRYPOINT [\"\/app\"]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In short, a multi-stage build uses two images. First, the large Go image compiles your code. Then only the finished binary moves into <code>scratch<\/code>, which is a completely empty image. For instance, the diagram below shows this hand-over.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-diagram-1024x640.png\" alt=\"Go Docker Deployment diagram showing a multi-stage build where only the static binary is copied into a scratch image\" class=\"wp-image-319\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-diagram-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-diagram-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-diagram-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-diagram-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-diagram-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>The build stage holds the Go toolchain and source code, but only the static binary is copied into the empty scratch image that you ship.<\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why Each Line Matters<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Line<\/th><th>What it does<\/th><\/tr><\/thead><tbody><tr><td><code>COPY go.mod go.sum* .\/<\/code> then <code>go mod download<\/code><\/td><td>Caches modules, so rebuilds are faster.<\/td><\/tr><tr><td><code>CGO_ENABLED=0<\/code><\/td><td>Makes a static binary that needs no C libraries.<\/td><\/tr><tr><td><code>-ldflags=\"-s -w\"<\/code><\/td><td>Drops debug data, so the file is smaller.<\/td><\/tr><tr><td><code>USER 65534:65534<\/code><\/td><td>Runs as a non-root user for safety.<\/td><\/tr><tr><td><code>ENTRYPOINT [\"\/app\"]<\/code><\/td><td>Starts your program when the container starts.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Building and Running the Image<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>$ docker build -t hello-go .\n$ docker images hello-go\nhello-go   latest   7.89MB\n\n$ docker run -d -p 8080:8080 hello-go\n$ curl localhost:8080\/hello\nHello from a container!\n\n$ docker run -d -e PORT=9090 -p 9090:9090 hello-go\n$ curl localhost:9090\/hello\nHello from a container!<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, the <code>-p 8080:8080<\/code> flag connects a port on your machine to the port inside the container. Meanwhile, <code>-e PORT=9090<\/code> sets an environment variable, so the same image runs on any port without a rebuild.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Keep the Build Context Small<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># .dockerignore\n.git\n*.md\napp<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For Go Docker deployment, a <code>.dockerignore<\/code> file stops Docker from sending useless files to the build. Therefore, builds start faster, and secrets in your folder stay out of the image.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Scratch vs Alpine for Go Docker Images<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Base image<\/th><th>Size<\/th><th>Good for<\/th><\/tr><\/thead><tbody><tr><td>scratch<\/td><td>about 8 MB here<\/td><td>Pure Go apps with no outside files<\/td><\/tr><tr><td>alpine<\/td><td>a few MB more<\/td><td>Apps that need a shell or CA certificates<\/td><\/tr><tr><td>distroless static<\/td><td>a little more than scratch<\/td><td>Certificates included, still no shell<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><code>scratch<\/code> is truly empty, so it has no shell and no CA certificates. However, if your app calls HTTPS services, it needs those certificates. In that case, copy them from the build stage or use a distroless or Alpine base instead.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Go Docker Deployment<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem you see<\/th><th>Why it happens<\/th><th>How to fix it<\/th><\/tr><\/thead><tbody><tr><td>exec \/app: no such file or directory<\/td><td>Because the binary was built with cgo and needs C libraries.<\/td><td>So build with <code>CGO_ENABLED=0<\/code>.<\/td><\/tr><tr><td>x509: certificate signed by unknown authority<\/td><td>Because scratch has no CA certificates.<\/td><td>So copy certificates or use distroless.<\/td><\/tr><tr><td>curl cannot connect to the app<\/td><td>Because the port was not published.<\/td><td>So add <code>-p 8080:8080<\/code> to <code>docker run<\/code>.<\/td><\/tr><tr><td>Image is over 800 MB<\/td><td>Because the final stage still uses the Go image.<\/td><td>So use a multi-stage build.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In fact, container questions are common in backend and DevOps interviews. So practise with my <a href=\"https:\/\/smitabharat.com\/blog\/go-lang-interview-questions-and-answers\/\">Go interview questions and answers<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These pages come from the Go and Docker teams, so they stay accurate and up to date.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/go.dev\/doc\/tutorial\/compile-install\">Go docs: Compile and install the application<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.docker.com\/reference\/dockerfile\/\">Docker docs: Dockerfile reference<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.docker.com\/build\/building\/multi-stage\/\">Docker docs: Multi-stage builds<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go Docker deployment ships one static binary inside a small image.<\/li>\n\n\n\n<li>A multi-stage build compiles in a big image and runs in a tiny one.<\/li>\n\n\n\n<li>Use <code>CGO_ENABLED=0<\/code> so the binary works in <code>scratch<\/code>.<\/li>\n\n\n\n<li>Publish ports with <code>-p<\/code> and pass settings with <code>-e<\/code>.<\/li>\n\n\n\n<li>Add CA certificates or use distroless when your app calls HTTPS.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">At last, your app runs in a container. Next, we will make it stop safely when the container shuts down, with graceful shutdown.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next lesson: <a href=\"https:\/\/smitabharat.com\/blog\/go-graceful-shutdown\/\">Go Graceful Shutdown for HTTP Servers Explained<\/a><\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Go Docker deployment packs your compiled program into a small container image that runs the same way on every server. In this post, you&hellip;<\/p>\n","protected":false},"author":1,"featured_media":318,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[15],"tags":[61,11,23,21],"swapz_series":[],"class_list":["post-328","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go-lang","tag-go-docker","tag-go-lang","tag-go-tutorial","tag-golang-basics"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Go Docker Deployment: Build Tiny Container Images<\/title>\n<meta name=\"description\" content=\"Learn Go Docker deployment step by step: build a static binary, write a multi-stage Dockerfile, use a scratch image and run your app.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go Docker Deployment: Build Tiny Container Images\" \/>\n<meta property=\"og:description\" content=\"Learn Go Docker deployment step by step: build a static binary, write a multi-stage Dockerfile, use a scratch image and run your app.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/\" \/>\n<meta property=\"og:site_name\" content=\"Smita Bharat - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-05-04T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-10T15:51:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Smita\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Smita\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/\"},\"author\":{\"name\":\"Smita\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"headline\":\"Go Docker Deployment: Build Tiny Container Images\",\"datePublished\":\"2026-05-04T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:51:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/\"},\"wordCount\":755,\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-docker-deployment-featured.png\",\"keywords\":[\"Go Docker\",\"Go Lang\",\"Go Tutorial\",\"Golang Basics\"],\"articleSection\":[\"Go Lang\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/\",\"name\":\"Go Docker Deployment: Build Tiny Container Images\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-docker-deployment-featured.png\",\"datePublished\":\"2026-05-04T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:51:04+00:00\",\"description\":\"Learn Go Docker deployment step by step: build a static binary, write a multi-stage Dockerfile, use a scratch image and run your app.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/#primaryimage\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-docker-deployment-featured.png\",\"contentUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-docker-deployment-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Go Docker Deployment featured image: cards for a multi-stage build, a static binary and a tiny scratch image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-docker-deployment\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go Docker Deployment: Build Tiny Container Images\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\",\"name\":\"Smita Bharat Blog\",\"description\":\"Golang &amp; Backend Development Tutorials and Interview Questions\",\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"alternateName\":\"Smita Bharat\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\",\"name\":\"Smita\",\"logo\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/smitabharat.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go Docker Deployment: Build Tiny Container Images","description":"Learn Go Docker deployment step by step: build a static binary, write a multi-stage Dockerfile, use a scratch image and run your app.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/","og_locale":"en_US","og_type":"article","og_title":"Go Docker Deployment: Build Tiny Container Images","og_description":"Learn Go Docker deployment step by step: build a static binary, write a multi-stage Dockerfile, use a scratch image and run your app.","og_url":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/","og_site_name":"Smita Bharat - Blog","article_published_time":"2026-05-04T03:30:00+00:00","article_modified_time":"2026-10-10T15:51:04+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-featured.png","type":"image\/png"}],"author":"Smita","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Smita","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/#article","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/"},"author":{"name":"Smita","@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"headline":"Go Docker Deployment: Build Tiny Container Images","datePublished":"2026-05-04T03:30:00+00:00","dateModified":"2026-10-10T15:51:04+00:00","mainEntityOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/"},"wordCount":755,"publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-featured.png","keywords":["Go Docker","Go Lang","Go Tutorial","Golang Basics"],"articleSection":["Go Lang"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/","url":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/","name":"Go Docker Deployment: Build Tiny Container Images","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/#primaryimage"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-featured.png","datePublished":"2026-05-04T03:30:00+00:00","dateModified":"2026-10-10T15:51:04+00:00","description":"Learn Go Docker deployment step by step: build a static binary, write a multi-stage Dockerfile, use a scratch image and run your app.","breadcrumb":{"@id":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smitabharat.com\/blog\/go-docker-deployment\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/#primaryimage","url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-featured.png","contentUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-docker-deployment-featured.png","width":2400,"height":1260,"caption":"Go Docker Deployment featured image: cards for a multi-stage build, a static binary and a tiny scratch image"},{"@type":"BreadcrumbList","@id":"https:\/\/smitabharat.com\/blog\/go-docker-deployment\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smitabharat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go Docker Deployment: Build Tiny Container Images"}]},{"@type":"WebSite","@id":"https:\/\/smitabharat.com\/blog\/#website","url":"https:\/\/smitabharat.com\/blog\/","name":"Smita Bharat Blog","description":"Golang &amp; Backend Development Tutorials and Interview Questions","publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"alternateName":"Smita Bharat","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smitabharat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339","name":"Smita","logo":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/smitabharat.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/comments?post=328"}],"version-history":[{"count":1,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/328\/revisions"}],"predecessor-version":[{"id":333,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/328\/revisions\/333"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media\/318"}],"wp:attachment":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media?parent=328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/categories?post=328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/tags?post=328"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}