📝How-to: run docker as my user

tags

#how-to

Add the following to Dockerfile.

RUN groupadd --gid 1002 rasen
RUN useradd -rm -d /home/rasen -s /bin/bash -g rasen -G sudo -u 1001 rasen
USER rasen
WORKDIR /home/rasen

where 1001 and 1002 are uid and gid, respectively. (Look them up with whoami.)

Next, run docker with the following flags:

sudo docker run --rm -v $HOME:$HOME -w $(pwd) -u $(id -u):$(id -g)