Disclaimer: This is very much an anti-pattern since it looks like you are trying to create something similar to a VM, or at the very least a pet that you modify in place rather than making all your changes via code and redeploying a new container for each change.
That disclaimer aside, you just need a command that will hang indefinitely. The most common one I've seen in a tail -f /dev/null
, e.g.:
FROM ubuntu:18.04
RUN apt update \
&& apt install -y \
cmake \
curl \
git \
jq \
libasound2-dev \
libglu1-mesa-dev \
libgtk2.0-dev \
libjack-jackd2-dev \
libx11-dev \
libxcursor-dev \
libxinerama-dev \
libxi-dev \
libxrandr-dev \
zlib1g-dev
CMD [ "tail", "-f", "/dev/null" ]
I've also rearranged the Dockerfile to merge the update and install commands, this is a best practice for Dockerfile's since it avoids having a stale apt update
command used from the cache when you change the apt install
command months later. Also, putting each package on a separate line is better for version control to see what changed if you add a single new package.
When using this, you would docker run -d --name your_container your_image
to run it in the background, and then docker exec -it your_container /bin/bash
to open a shell.