Base OS to be run and configures

Hello community,

I’m kind of on the fence…my goal is to run a operating system within Docker to be configured while logging in to add some services and applications in order to generate an image with the running container.

e.g. Running Python in idle mode, install a package like “fritzconnection” or running a slim-debian or ubuntu system in idle mode, install for instance a list of packages (python, vs code, …) and save it as image to be used for others containers.

Can someone untie the knot in my head? I can create the image using a Dockerfile, but the container does not start (“idle mode”). What kind of command is needed here? It would be great if someone could help me with the “python example”.

# base image: Debian Buster slim with Python 3.9.1
FROM python:3.9.1-slim-buster

# disable pip's cache to reduce image size
ENV PIP_NO_CACHE_DIR=1

# update pip
RUN pip install -U \
    pip \
    setuptools \
    wheel

# change workdir
WORKDIR /usr/src/

# create new non-root user
RUN useradd -m -r user

# run as `user` instead of root
USER user

# run application
CMD ["python"]   *# the issue seems to be in this line*

Either you build the image in a way that ENTRYPOINT and/or CMD starts a foreground process that keeps the container running OR you leave the container as is and start your container with -t (docker run) or tty: true (compose) to keep it up and running.

1 Like

As soon as you know the right syntax, it feels very simple :smiley: THANKS for your quick help.