I am new with Docker and I am having trouble writing my Dockerfile. The thing is that I created a user named jonas523 which I want to execute a shell command. So I put it in this Dockerfile and when I go inside my fresh container, I observe that the command was not used with the new user I created.
I think I didn't understand the USER instruction provided by Docker:
USER jonas523
RUN \
echo "JAVA_HOME=/usr/java/jdk1.7.0_45/bin" >> /home/jonas523/.bash_profile \
&& echo "ANT_HOME=/opt/apache-ant-1.8.2/bin" >> /home/jonas523/.bash_profile \
&& echo "export JAVA_HOME" >> /home/jonas523/.bash_profile \
&& echo "export ANT_HOME" >> /home/jonas523/.bash_profile \
&& echo "PATH=$PATH:$HOME/bin:$JAVA_HOME:$ANT_HOME" >> /home/jonas523/.bash_profile \
&& echo "export PATH" >> /home/jonas523/.bash_profile
RUN source ~/.bash_profile
Could anyone tell me about using of the USER instruction. What is the difference between the RUN and CMD instructions?
Thanks.