Docker build fails due to cannot load package

The docker build fails whenever I run "docker build . "
It says cannot load package A/B/C: module A/B@latest found (v0.0.0-20200130130556-6a5cffbc99af), but does not contain package A/B/C.


Step 1/8 : FROM golang:1.13
—> 6586e3d10e96
Step 2/8 : RUN printf “***” > ~/.netrc ## build account on bitbucket
—> Using cache
—> afccf96ed6c0
Step 3/8 : RUN mkdir -p /go/src/
—> Using cache
—> af2c1ce54ce5
Step 4/8 : COPY . /go/src/
—> ebec6a06817d
Step 5/8 : WORKDIR /go/src/
—> Running in 0a332bb434b7
Removing intermediate container 0a332bb434b7
—> 1dcdac500f07
Step 6/8 : RUN mkdir /go/log && go build -o /go/bin
—> Running in 26e0514769e9
go: downloading v0.0.0-20200130130556-6a5cffbc99af
go: downloading v1.7.3
go: downloading v1.1.1
go: downloading v1.4.2
go: downloading v1.2.1
go: extracting v1.1.1
go: extracting v1.4.2
go: extracting v1.7.3
go: extracting v0.0.0-20200130130556-6a5cffbc99af
go: extracting v1.2.1
go: downloading v0.0.1
go: downloading v1.8.0
go: downloading v1.4.4
go: extracting v1.8.0
go: extracting v0.0.1
go: extracting v1.4.4
go: finding latest
go: finding latest
go: finding v1.1.1
go: finding v1.4.2
go: finding v1.7.3
go: finding v1.2.1
go: finding v1.8.0
go: finding v1.4.4
go: finding v0.0.1
build cannot load module found (v0.0.0-20200130130556-6a5cffbc99af), but does not contain package
The command ‘/bin/sh -c mkdir /go/log && go build -o /go/bin’ returned a non-zero code: 1


$ go build

work if you don’t try to build a Docker container? The module does not exist or is not accessible.

go build works fine.
The module is not accessible because it is an organization’s private module.

Do you have a go.sum in your project when you clone it?

If not, does the package in the module actually exist on the commit that the error complaints about?

If you have a go.mod in your local project, but not in git, check if the SHA in the sum file is the same as in the error. Compare if the package has been removed since then.

To be sure, do a fresh clone outside of docker on your Dev pc and try to build it. Do not use your already existing clone. What happens there?

yes, I do have a go.sum in my project and the package is also present in the module on that commit.
SHA in the sum file is the same as in the error and the package is still present.
Outside of docker the build works fine but it again fails if built with docker,
err : build cannot load module found (v0.0.0-20200130130556-6a5cffbc99af), but does not contain package

Does it work if you make the repositories public temporarily (I know this might be a potential risk for your company and I totally understand if you don’t want to try)?

Also have you checked non-docker build on a fresh clone?

I found the solution.
The imported package had repo name mongoMgr but the package name is mongomgr. I matched the package name and the repo name, now the built is successfull.

Although one new query arrises as to how do we resolve such built when package name is diff then repo name.

thanks Nobert

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.