Video:

Creating A Dockerfile

January 9, 2022

Course Instructor: Elliot Forbes

Hey Gophers! My name is Elliot and I'm the creator of TutorialEdge and I've been working with Go systems for roughly 5 years now.

Twitter: @Elliot_f

Now that we’ve covered the high-level concepts of Docker and containerization as a whole, let’s dive into our code editor and start building out our own docker images and containers.

A Lightweight Dockerfile

The first thing we want to do is create our own docker image that we’ll later run as a container.

Let’s start by creating a file with the name Dockerfile within our project. We then want to start defining each layer of this Dockerfile.

We’ll start with a base layer, this will be alpine for now. This is a nice, lightweight image that has been specifically stripped of all the non-essentials libraries and packages with the intention .

Dockerfile
FROM apline
WORKDIR /app

Building an Image

$ docker build -t my-image-name .

Running As A Container

$ docker run -it my-image-name

Building for Go Apps

FROM golang
RUN go build -o main ./...
CMD ["./main"]