Skip to content

Conversation

@hexial
Copy link

@hexial hexial commented Dec 17, 2023

Hi

I wanted to install some application and setup some things when building my docker image that used docker-remote-desktop. But these commands I want to run as the ubuntu user. Since that user is created in entrypoint.sh the ubuntu user is not available during docker build phase.

My proposal to this is to have the user created in Dockerfile and then my Dockerfile could look something like this, if my docker image needs to download an app from some where and unpack it in my home folder. Or do other things as the ubuntu user during build phase.

FROM scottyhardy/docker-remote-desktop
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update &&  \
    apt-get install -y \
    wget
USER ubuntu
RUN cd /home/ubuntu && \
    wget https://url-to-something/app.tar.gz && \
    tar -zxf app.tar.gz
USER root

@scottyhardy
Copy link
Owner

The reason I create the user account in the entrypoint is because this project is a dependency for my docker-wine project. The entrypoint is a simplified version of the one that docker-wine uses which allows for the secure creation of any user account on instantiation.

I’d suggest using root for install then chown after if required. Apt requires sudo (root) anyways and even binaries you download should generally be copied or symlinked to /usr/local/bin/ and use chmod +x to allow any user to run it and also without needing to specify path. (e.g. mybinary instead of ./mybinary)

There are occasional times when you need to run as a user though, so only in those circumstances would I bother to do the extra work. And you’ve pretty much worked out how to do it, you just need to combine your changes in the commit to your code above, so the account creation is performed in your own Dockerfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants