1

Anyone know why podman fails and docker works?

podman:

$ podman run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.20 go build -v
go: go.mod file not found in current directory or any parent directory; see 'go help modules'

docker:

$ sudo docker  run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.20 go build -v
go: downloading github.com/spf13/cobra v1.7.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
go: downloading github.com/a8m/envsubst v1.4.2
go: downloading github.com/alecthomas/participle/v2 v2.0.0
go: downloading github.com/dimchansky/utfbom v1.1.1
.. and so on resulting in an artefact

1 Answer 1

1

A bit of checking gave that the container user did not have read access to the mounted volume:

$ podman run --rm  -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.20 /bin/bash -c "id; ls -l /usr/src/; ls -l /usr/src/myapp"
uid=0(root) gid=0(root) groups=0(root)
total 4
drwxr-xr-x. 12 root root 4096 Jul 19 10:19 myapp
ls: cannot open directory '/usr/src/myapp': Permission denied

This in turn gave me som additional google material that lead me to this answer on devops.stackexchange

tl;dr answer

  • I have selinux enabled on my host that gives permission problems
  • Change -v "$PWD":/usr/src/myapp to -v "$PWD":/usr/src/myapp:z

Some more reading about this :z can be found here https://unix.stackexchange.com/q/651198/2298

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .