Dockerfile of Vim + Plugins and .vimrc What follows is a Dockerfile for my Vim settings, so I could use it anywhere.
While it is public, it is not intended for mass usage, and so the face that it creates the password in the build process isn't a problem.
There is no COMMAND at the end because it is intended to be run with mount. The command I run it with docker run -itv /:/tmp/real_root uberhumus/vim-anywhere:latest vi &lt;Filename&gt;
Was I supposed to COPY the .vimrc later? Or use ADD instead? Am I too splurgy with the layers? Is there a smarter way to do the RUN, WORKDIR, RUN situations I ran into?
Thanks!

ENV DEBIAN_FRONTEND=noninteractive
ARG TZ=Asia/Jerusalem
RUN apt-get update; \
    apt-get dist-upgrade -y &amp;&amp; \
    apt-get autoremove -y &amp;&amp; \
    apt-get autoclean -y &amp;&amp; \
    apt-get install -y vim tmux bash-completion shellcheck ssh git pylint flake8 python sudo expect curl cmake build-essential python3-dev golang npm openjdk-11-jre exuberant-ctags &amp;&amp; \
    echo vim-anywhere &gt; /etc/hostname

ARG USERNAME=yotam
RUN PASSWORD=$(openssl rand -base64 16 | tr -d &quot;=&quot;) &amp;&amp; \
    useradd -m -s /bin/bash $USERNAME &amp;&amp; \
    usermod -aG sudo $USERNAME &amp;&amp; \ 
    echo &quot;$USERNAME:$PASSWORD&quot; | chpasswd &amp;&amp; \
    echo $PASSWORD

WORKDIR /home/$USERNAME
COPY .vimrc .
RUN mkdir -p ./.vim/pack/plugins/start 
WORKDIR /home/$USERNAME/.vim/pack/plugins/start
RUN git clone https://github.com/tpope/vim-fugitive.git/ &amp;&amp; \
    git clone --depth 1 https://github.com/dense-analysis/ale.git &amp;&amp; \
    git clone https://github.com/ycm-core/YouCompleteMe.git
WORKDIR /home/$USERNAME/.vim/pack/plugins/start/YouCompleteMe
RUN git submodule update --init --recursive &amp;&amp; \
    python3 install.py --all &amp;&amp; \
    chown -R $USERNAME:$USERNAME /home/$USERNAME
USER $USERNAME```
The best I've got is:
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive
ARG TZ=Asia/Jerusalem
ARG USERNAME=yotam
RUN apt-get update; \
    apt-get dist-upgrade -y &amp;&amp; \
    apt-get autoremove -y &amp;&amp; \
    apt-get autoclean -y &amp;&amp; \
    apt-get install -y vim tmux bash-completion shellcheck ssh git pylint flake8 python sudo expect curl cmake build-essential python3-dev golang npm openjdk-11-jre exuberant-ctags &amp;&amp; \
    useradd -m -s /bin/bash $USERNAME &amp;&amp; \
    usermod -aG sudo $USERNAME &amp;&amp; \ 
    echo vim-anywhere &gt; /etc/hostname

WORKDIR /home/$USERNAME
COPY .vimrc .
RUN mkdir -p ./.vim/pack/plugins/start 
WORKDIR /home/$USERNAME/.vim/pack/plugins/start
RUN git clone https://github.com/tpope/vim-fugitive.git/ &amp;&amp; \
    git clone --depth 1 https://github.com/dense-analysis/ale.git &amp;&amp; \
    git clone https://github.com/ycm-core/YouCompleteMe.git
WORKDIR /home/$USERNAME/.vim/pack/plugins/start/YouCompleteMe
RUN git submodule update --init --recursive &amp;&amp; \
    python3 install.py --all &amp;&amp; \
    chown -R $USERNAME:$USERNAME /home/$USERNAME &amp;&amp; \
    PASSWORD=$(openssl rand -base64 16 | tr -d &quot;=&quot;) &amp;&amp; \
    echo &quot;$USERNAME:$PASSWORD&quot; | chpasswd &amp;&amp; \
    echo $PASSWORD
WORKDIR /home/$USERNAME
USER $USERNAME

This gives me only minor advantages which are:

The password is echoed at the end of the build and is easier to find in the output.
The return to the homedir at the end is more what you'd intuitively expect.