GoogleCloudPlatform / GoogleCloudPlatform/gcsfuse
`panic: user: unknown userid` in a non-root container without user mapping
- Dominant language
- Go
- Stars
- 2.3k
- Forks
- 510
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 35
Description
gcsfuse (at least the latest 0.41.10 that I tried) panics in a non-root container without a user mapping.
An example with Bitnami Wordpress image:
1. `docker pull bitnami/wordpress`
2. `docker inspect bitnami/wordpress:latest | grep -i user`:
```
"User": "1001",
"User": "1001",
```
4. Adapt this [Google's example](https://cloud.google.com/run/docs/tutorials/network-filesystems-fuse#cloudrun_fs_dockerfile-python) to try Wordpress on Cloud Run with gcsfuse (not providing details here - irrelevant).
5. Deploy to Cloud Run and observe the error for command `gcsfuse --debug_gcs --debug_fuse --foreground $BUCKET /mnt/gcs`:
```
2023-01-02 14:07:26.969 CET Start gcsfuse/0.41.10 (Go version go1.18.4) for app "" using mount point: /mnt/gcs
2023-01-02 14:07:26.969 CET Opening GCS connection...
2023-01-02 14:07:26.973 CET Creating a mount at "/mnt/gcs"
2023-01-02 14:07:26.978 CET Container called exit(2).
2023-01-02 14:07:26.979 CET panic: user: unknown userid 1001 goroutine 1 [running]: github.com/googlecloudplatform/gcsfuse/internal/perms.MyUserAndGroup() /tmp/build_gcsfuse_gopath2289345396/src/github.com/googlecloudplatform/gcsfuse/internal/perms/perms.go:29 +0x1c5 main.mountWithConn({0x109de80, 0xc0001340c8}, {0x7ffefd44d5f0, 0x10}, {0x7ffefd44d601, 0x8}, 0xc000402420, 0x50?, {0x0, 0x0}, ...) /tmp/build_gcsfuse_gopath2289345396/src/github.com/googlecloudplatform/gcsfuse/mount.go:65 +0x131 main.mountWithArgs({0x7ffefd44d5f0, 0x10}, {0x7ffefd44d601, 0x8}, 0xc000402420, 0x6?) /tmp/build_gcsfuse_gopath2289345396/src/github.com/googlecloudplatform/gcsfuse/main.go:198 +0x2d2 main.runCLIApp(0xc0005bf8f8?) /tmp/build_gcsfuse_gopath2289345396/src/github.com/googlecloudplatform/gcsfuse/main.go:362 +0xef3 main.run.func1(0x1?) /tmp/build_gcsfuse_gopath2289345396/src/github.com/googlecloudplatform/gcsfuse/main.go:397 +0x25 github.com/googlecloudplatform/gcsfuse/vendor/github.com/urfave/cli.HandleAction({0xc94280?, 0xc0000443c0?}, 0xc0004c0e00?) /tmp/build_gcsfuse_gopath2289345396/src/github.com/googlecloudplatform/gcsfuse/vendor/github.com/urfave/cli/app.go:526 +0x50 github.com/googlecloudplatform/gcsfuse/vendor/github.com/urfave/cli.(*App).Run(0xc0004c0e00, {0xc00012c120, 0x6, 0x6}) /tmp/build_gcsfuse_gopath2289345396/src/github.com/googlecloudplatform/gcsfuse/vendor/github.com/urfave/cli/app.go:286 +0x7c5 main.run() /tmp/build_gcsfuse_gopath2289345396/src/github.com/googlecloudplatform/gcsfuse/main.go:401 +0xc5 main.main() /tmp/build_gcsfuse_gopath2289345396/src/github.com/googlecloudplatform/gcsfuse/main.go:419 +0x4a
```
Edit: FYI, the issue is gone after giving the user `1001` a name in my Dockerfile derived from the Bitnami Wordpress image, as follows:
```
FROM bitnami/wordpress:latest
(...)
USER 0
RUN useradd --uid 1001 --no-create-home anynameyoulike
USER 1001
(...)
```
That's only a workaround though.
Contributor guide
Assessment
This issue has not been assessed yet.