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 .
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"]