hands-on lab

Containerizing Go Applications with Docker: Advanced

Difficulty: Intermediate
Duration: Up to 1 hour
Students: 220
Rating: 4.8/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.

Description

In the previous lab, you created a simple command line utility and were able to containerize it with Docker. This lab will cover advanced topics of containerizing Go applications. In this lab, you'll containerize a simple web server application. This web server uses Go modules to handle dependencies and you'll learn how to manage them when building a Docker image. You'll also learn about the Docker multi-stage build pattern, and how to expose ports when running a Docker image.

Learning Objectives

Upon completion of this lab you will be able to:

  • Add third party libraries to Go source code using Go modules
  • Write a Dockerfile capable of managing third-party libraries in a Go application
  • Build the Docker image
  • Refactor the Dockerfile to use a multi-stage build architecture, and leverage Docker build caching

Intended Audience

This lab is intended for:

  • Developers, especially those working with Go
  • Anyone leveraging containers

Prerequisites

You should possess:

  • Basic understanding of the Go programming language
  • Understanding of the Linux command line
  • Conceptual understanding of Docker

The following content is sufficient to fulfill these prerequisites:

Updates

August 17th, 2021 - Addressed an issue and clarified some instructions

Covered topics

Lab steps

Connecting to the Go Development Environment
Working with Go Modules
Building and Testing the Greeter Server
Containerizing greeter-server with Docker
Refactoring Docker Builds