I have this Dockerfile:
FROM ubuntu:bionic
RUN mkdir /usr/custom
ADD script.sh /usr/custom
RUN chmod =rx /usr/custom/script.sh
RUN useradd -ms /bin/bash -u 1001 someusr
USER someusr
WORKDIR /home/someusr
where script.sh (it is in the same directory as Dockerfile) contains:
#!/bin/bash
whoami
Build the image with:
docker image build --tag my_ubuntu_bionic:auto .
Then run it with:
docker run --rm --user=1001 my_ubuntu_bionic:auto /usr/custom/script.sh
and it displays root.
How can I run this as someusr?
Thank you