ipfs / ipfs/kubo

Docker: UID 1000 owns ipfs process - undesired results on host systems already using UID 1000

Open
#9,117 4 comments 0 reactions 0 assignees View on GitHub
kind/bug need/triage
Dominant language
Go
Stars
17.1k
Forks
3.2k
Avg merge
3d 18h
Merged PRs (30d)
11

Description

### Checklist

- [X] This is a bug report, not a question. Ask questions on [discuss.ipfs.io](https://discuss.ipfs.io).
- [X] I have searched on the [issue tracker](https://github.com/ipfs/kubo/issues?q=is%3Aissue) for my bug.
- [X] I am running the latest [kubo version](https://dist.ipfs.io/#kubo) or have an issue updating.

### Installation method

built from source

### Version

```Text
Docker latest
```

### Config

```json
Docker latest
```

### Description

I am running in Docker and this line in Dockerfile forces the ipfs command process to run as UID 1000, which on host systems already allocating this UID produces the undesired effect of running the ipfs process as owned by an unrelated user name:
```
&& adduser -D -h $IPFS_PATH -u 1000 -G users ipfs
```
![image](https://user-images.githubusercontent.com/1558610/179261505-2b9129a5-cfea-4f57-93a8-f33169e69398.png)

My host system has an ipfs user configured as UID 1004 (owner of the ipfs data volume), and editing this line to its UID correctly spawns ipfs process owned by ipfs user:
```
&& adduser -D -h $IPFS_PATH -u 1004 -G users ipfs
```
![image](https://user-images.githubusercontent.com/1558610/179260233-d01d0e3a-f685-401a-a5ba-2a626221cd4b.png)

The issue is obvious: statically setting this UID is problematic. I've been trying to find a way around it but have not come up with a working solution. Would increasing the UID to something like 1099 make more sense to avoid this type of user issue?

Or would it be possible to tell Dockerfile that if a local ipfs user exists on the host system to then adopt their UID? I've tried things like this to no avail because it's checking for that user in the container and not the host system:
```
&& if $(id -u ipfs >/dev/null 2>&1); then USER_ID=`id -u ipfs`; else USER_ID=1000; fi \
&& adduser -D -h $IPFS_PATH -u $USER_ID -G users ipfs \
```

Possibly using ENV variable in Dockerfile or alternatively an argument passed via docker run command? Any leads? TIA

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.