The parent image I am using seems to require root access to run its ENTRYPOINT
instruction.
In my Dockerfile
I need to run my own container (executable) with normal user at the end. How do I switch back and forth between users here?
Psuedo Dockerfile:
FROM parentrepo/parentimg # its Dockerfile probably has ENTRYPOINT at the end which requires root access
#my app specific instructions
WORKDIR ..
RUN mkdir ..
COPY ..
RUN tar ..
EXPOSE 9000
USER nir # HEre i want to switch user to nir
WORKDIR ${myhome}
CMD ["/bin/bash", "-c", "./start"]
Running above fails as parent requires sudo access. if I don't do USER nir
then my process starts as root user which i don't want. Does the parent Dockerfile need to have USER root
here ?
Also, Is there any document that describe how docker Build
execute instructions at high level? . How it interacts with hierarchies of parent Dockerfiles. Looks like it imports instructions from parent docker files; creates one docker file. Does it reorder instruction in anyway?
ANd what happens at runtime which executing via docker run
? I know RUN
command is used at build time while CMD
and ENTRYPOINT
executed at runtime but it still doesn't explain whole picture and sequences from build otherwise it would have been clear what I need to do.