In this section, you will learn how to put kvTCP.go into a Docker image and use it from there, which is a pretty convenient way of using a TCP/IP application because a Docker image can be easily transferred to other machines or deployed in Kubernetes.
As you might expect, everything will begin with a Dockerfile, which will have the following contents:
FROM golang:latest RUN mkdir /files COPY kvTCP.go /files WORKDIR /files RUN go build -o /files/kvTCP kvTCP.go ENTRYPOINT ["/files/kvTCP","80"]
After that, you will need to build the Docker image, as follows:
$ docker build -t kvtcp:latest . Sending build context to Docker daemon 6.656kB Step 1/6 : FROM golang:latest ---> 7ced090ee82e Step 2/6 : RUN mkdir /files ---> Running in bbbbada6271f Removing intermediate container bbbbada6271f ---> 5b0a621eee29...