Docker container with git-daemon keeps stopping

163 Views Asked by At

Not sure whether it's my misunderstanding of docker, git-daemon, general linux-fu or all of the above, but having set up one inside the other I'm noticing that the container will run for around 20 seconds, then just exit.

  • I set up a simple dockerfile, to install git, git-daemon-run and a git user.
  • I then USER: git and the entrypoint runs the daemon with --base-path set to the user's home directory.
  • Call docker run with the -d flag.
  • Check every few seconds on container with docker ps.
  • Everything is fine for a few checks, then suddenly the container is stopped.

Steps taken:

  • Running docker logs ... shows: error: waitpid for git-daemon failed: No child processes. But googling that doesn't get me very far.
  • Read git-daemon doesn't run as a daemon by default so amended the entrypoint to include --detach but that just means the container doesn't stay alive at all and the logs are empty.
  • Run container with -it instead of -d and I observe the same behaviour.
  • Use docker exec to init a repo inside the container to give the daemon "something to share" but still shuts down.

I had been playing around with this setup previously and I thought it had been working. What am I missing, not following?

Update:

The exit code given for the container is (128) which I'm struggling to find documentation on. Best I have is that 128 + n Is fatal signal error n but under the man page for signal I can't find signal 0.

Dockerfile:

FROM ubuntu:22.04

RUN apt-get -y update && apt-get -y install git 
RUN apt-get -y install git-daemon-run
EXPOSE 9418

RUN useradd -m -s /bin/bash git && chown -R git:git /home/git

USER git
WORKDIR /home/git

ENTRYPOINT [ "git", "daemon", "--base-path=/home/git", "--export-all", "--reuseaddr", "--enable=receive-pack" ]

Docker build & run commands:

docker build -t git-daemon . -f ./dockerfiles/git.daemon.dockerfile
docker create network docknet-0
docker run --name gitsrv -d --network=docknet-0 -p 9418:9418 git-daemon

Update:

The problem would appear to be related to running the docker engine as rootless. The container will only stay alive so long as the user I'm using to run the engine (in my case docker/1001) is logged into the system. If I SSH in as this user the container does not stop but the waitpid error is triggered when I terminate the connection. Changing the user within the container (i.e. leaving that as root instead of git) doesn't make a difference.

0

There are 0 best solutions below