Answers
Here are possible answers to this chapter’s questions:
- The Dockerfile could look like this:
FROM ubuntu:22.04RUN apt-get update && \apt-get install -y iputils-pingCMD ping 127.0.0.1
Note that in Ubuntu, the ping
tool is part of the iputils-ping
package. You can build the image called pinger – for example – with the following command:
$ docker image build -t mypinger .
- The Dockerfile could look like this:
FROM alpine:latestRUN apk update && \apk add curl
Build the image with the following command:
$ docker image build -t my-alpine:1.0 .
- The Dockerfile for a Go application could look like this:
FROM golang:alpineWORKDIR /appADD . /appRUN go env -w GO111MODULE=offRUN cd /app && go build -o goappENTRYPOINT ./goapp
You can find the full solution in the ~/The-Ultimate-Docker-Container-Book/sample-solutions/ch04/answer03
folder.
- A Docker image has the following characteristics:
- It is immutable...