If I run the docker exec it is always root
user.
The requirement is to always docker exec other than root
user still the entrypoint needs to run root
some of the sshd config changes and it's restarting. I can't change the user permissions as well to accommodate to change ssh config
is there way to remove root user from bash when I did su
in entrypoint.sh
When I do docker exec it should be an example user only, I understand that it is only possible through USER
command https://docs.docker.com/engine/reference/builder/#user
I have tried multiple solutions with docker and dokcer-composer still no success.
For example here https://stackoverflow.com/a/47410394/358458
I am just copying and pasting some of the content to understand my question more.
Dokcerfile
FROM ubuntu:latest
RUN useradd -ms /bin/bash exemple
COPY entrypoint.sh /root/entrypoint.sh
ENTRYPOINT "/root/entrypoint.sh"
entrypoint.sh
#!/bin/bash
id
echo 'Banner /usr/bin/custom-banner' >> /etc/ssh/sshd_config
rm -f /etc/ssh/ssh_host_dsa_*
su - exemple
cd /home/example
id
$ docker build -t so-test .
$ docker run --rm -it so-test bash
I am root
uid=0(root) gid=0(root) groups=0(root)
exemple@37b01e316a95:~$ id
uid=1000(exemple) gid=1000(exemple) groups=1000(exemple)