Create a Dockerfile for a Go application that uses multi-stage builds to reduce the final image size
Question
package main
import "fmt"
func main() {
fmt.Println("Hello Docker")
}Solution
FROM golang:1.21.0-alpine
WORKDIR /app
COPY app.go /app
CMD ["go", "run", "app.go"]



Let's try using the multistage build,


PreviousRun a container from the ubuntu image and start an interactive shell session inside it.NextCreate a Docker volume and use it to persist data for a MySQL container.
Last updated