PacktWorkshops / The-Docker-Workshop

35 stars 58 forks source link

Exercise4.01 dockerfile doesn't work with 'latest' tag #53

Open beepmode opened 2 years ago

beepmode commented 2 years ago

As explained in the book, it's best not to use the 'latest' tag. The dockerfile used for exercise 4.01 doesn't work with when you use the 'latest' tag:

# docker build -t welcome:v1 .
Sending build context to Docker daemon  3.072kB
Step 1/5 : FROM golang:latest
latest: Pulling from library/golang
0e29546d541c: Pull complete 
9b829c73b52b: Pull complete 
cb5b7ae36172: Pull complete 
6494e4811622: Pull complete 
6e1d20a8313e: Pull complete 
593823f101dc: Pull complete 
1b4aae56cdbe: Pull complete 
Digest: sha256:c72fa9afc50b3303e8044cf28fb358b48032a548e1825819420fd40155a131cb
Status: Downloaded newer image for golang:latest
 ---> 276895edf967
Step 2/5 : WORKDIR /myapp
 ---> Running in 953c447838bd
Removing intermediate container 953c447838bd
 ---> e14020f0e3c4
Step 3/5 : COPY welcome.go .
 ---> 0b6cd120c7b6
Step 4/5 : RUN go build -o welcome .
 ---> Running in 1ee6f592b952
go: go.mod file not found in current directory or any parent directory; see 'go help modules'
The command '/bin/sh -c go build -o welcome .' returned a non-zero code: 1

I think this is because of changes introduced in version 1.16 of Golang. It works if I use FROM golang:1.15.

CJavierSaldana commented 2 years ago

Hi @beepmode, you can see my PR.

https://github.com/PacktWorkshops/The-Docker-Workshop/pull/57