Run plone-backend without starting plone

How do I run a "plone-backend" docker container without starting plone, do some modifications and start plone later?

building your own image?

There are different methods to do that. With pros and cons. Here some examples:

Overwrite the default entrypoint of the image with some simple background process like sleep infinity or tail -f /dev/null.

# create and run a new container named "mycontainer"
# from image "plone/plone-backend:6.1.2"
# overwrite the default entrypoint of the image with "sleep infinity"
docker run -d \
    -p 8080:8080 \
    --name mycontainer \
    --entrypoint '' \
    plone/plone-backend:6.1.2 \
    sleep infinity

# execute a bash shell in your container to do something
docker exec -it mycontainer /bin/bash

# do something
...
# exit the shell
exit

# execute "/app/docker-entrypoint.sh start" to start plone
docker exec -d mycontainer /app/docker-entrypoint.sh start

Starting plone (i.e. runwsgi) when the container is already running has also the advantage that runwsgi will not become PID 1 and you'll be able to kill it if necessary.


Or simply run a new container and enter the bash directly

docker run -it \
    -p 8080:8080 \
    --name mycontainer \
    --entrypoint /bin/bash \
    plone/plone-backend:6.1.2

# do something
...

# call "/app/docker-entrypoint.sh start" to start plone
/app/docker-entrypoint.sh start

# exit the shell
exit

This method has the disadvantage that it exits the container and it must be started again.


Or you could do the same with docker compose:

cat <<'EOF' | tee mycontainer.yaml
services:
  mycontainer:
    container_name: mycontainer
    image: plone/plone-backend:6.1.2
    ports: [ "8080:8080" ]
    entrypoint: []
    command: [ "sleep", "infinity" ]
EOF
docker compose -f mycontainer.yaml up -d
docker exec -it mycontainer /bin/bash
# do something
...
# exit the shell
docker exec -d mycontainer /app/docker-entrypoint.sh start

Or (as @yurj pointed out) build your own image with own entrypoint and cmd

cat <<'EOF' > Dockerfile
FROM plone/plone-backend:6.1.2
ENTRYPOINT []
CMD [ "sleep", "infinity" ]
EOF
docker build -t myimage .
docker run -d -p 8080:8080 --name mycontainer myimage
docker exec -it mycontainer /bin/bash

# do something
...
# exit the shell

docker exec -d mycontainer /app/docker-entrypoint.sh start

Thank you.

How can I stop a running plone in a container.

If the runwsgi process is running in the foreground press Ctrl+C. If it is in the background you can bring it into the foreground with jobs and fg.

Or get the process id (PID) of the runwsgi process with ps -a:

ps -a

  PID   USER     COMMAND
  ...
  1234 plone    {runwsgi} /app/bin/python /app/bin/runwsgi -v etc/zope.ini config_file=zope.conf
  ...

And send a termination or kill signal with kill -s <SIGSPEC> <PID>

kill -s SIGTERM 1234
# or
kill -s SIGKILL 1234

You can call ps and kill either inside the container entering a bash session or outside the container with the docker exec subcommand.