Doesn't work with recent systemd and/or docker releases #50
Comments
I tried this and some other tricks, and each breaks in an interesting way. The right solution is
Here is #!/bin/bash
function docker_cleanup {
docker exec $IMAGE bash -c "if [ -f $PIDFILE ]; then kill -TERM -\$(cat $PIDFILE); rm $PIDFILE; fi"
}
IMAGE=$1
PIDFILE=/tmp/docker-exec-$$
shift
trap 'kill $PID; docker_cleanup $IMAGE $PIDFILE' TERM INT
docker exec $IMAGE bash -c "echo \"\$\$\" > $PIDFILE; exec $*" &
PID=$!
wait $PID
trap - TERM INT
wait $PID This way I can also exec multiple services in the same container. |
which docker and systemd version makes it break? |
Fedora 24 had 1.10.3 which worked. I'm now on 1.13.1 which isn't. systemd went from 229 to 233. |
Broken on docker 17.12 and Debian stretch, fails with this error:
Updating the vendored docker client fixes it. |
Same failure on Ubuntu 16.04.3 What did you mean "Updating the vendored docker client" ?? |
@Halfwalker I'm guessing it's these projects. Does Go not have a better solution than "embed source code" for dependency management? |
@Halfwalker here is what worked for me - I've built the executable in fresh golang container and then checked the binary on Ubuntu 16.04.3 LTS go get github.com/agend07/systemd-docker |
I'm wondering how much it's really needed ... Plain old docker run --rm .... in the systemd unit file seems to be working fine. I can systemctl start|stop my_container and it all seems to work OK. |
@Halfwalker What |
I used Plex as a test container - figured that would be a good stressor ...
All the testing was done in a virtualbox VM. Regular systemctl start/stop plex worked fine. Rebooting the box worked fine. |
I dont think it would work fine if the plex container crashed - as long as docker service would keep working systemd wouldn't know anything wrong happend cause it would monitor docker service, not your plex container. It is the part that when u start docker container u talk to docker, and docker starts another process (with plex) - which confuses systemd. So check if systemd would restart your plex container after u kill it with 'kill pid' or 'docker kill' |
Right - then systemd is monitoring docker, not the plex process in docker. With the unit file above though, docker would do the restart of the plex container. So while systemd wouldn't know that the plex container took a hit and restarted, the end result is the same : the plex container was restarted. systemd would only step in if docker itself died. My preference would be for systemd to know about plex though, via systemd-docker. That just seems much cleaner. A new build of systemd-docker seems to work. I've been pulling systemd-docker in via ansible for installs, but had to switch to plain docker run when it started failing. Now looking at what's needed to actually build a "latest" systemd-docker on a target system via ansible. @agend07 are you going to do a new release to handle the latest docker ? |
Here's a simple way to build a new version of systemd-docker if you don't want to install golang etc. Requires docker though :)
|
i just updated from 16.04.x to 18.04.1 and now my docker-systemd is broken (error: json: cannot unmarshal object into Go value of type string) unfortunately i cant test by building my own version because "go get github.com/agend07/systemd-docker" gives my an error: fatal: repository 'https://github.com/weaveworks/docker/' not found what can i do to get it working again? |
@firex2 try to build it again, I forked some repo with mflag into mine github. It's building but I'm not sure it would work on 18.04.1 |
build was fine this time, but getting errors upon starting
|
@firex2 try to google: '/sys/fs/cgroup/system.slice/docker.service/cgroup.procs: no such file or directory' what i found: moby/moby#17653 (there is some possible workaround (moby/moby#17653 (comment)) does it happen when you run the service with plain docker (instead of systemd-docker)? |
if i run it from plain command line, everything is fine with just "docker run ..." if i only change from systemd-docker to docker in my systemd-service it cannot start because of timeout it does not help to add "{"exec-opts": ["native.cgroupdriver=systemd"]}" in the docker config file
|
I was able to get systemd-docker working with Ubuntu 18.04 by:
My guess is that docker defaults to not using systemd for cgroups because "the delegate issues still exists and systemd currently does not support the cgroup feature set required for containers run by docker" (per the docker.service unit file), and I expect systemd-docker is expecting systemd for the cgroups, hence the |
You can get a binary for AMD64 Linux (tested on CoreOS and Ubuntu 18.04) at https://github.com/subdavis/systemd-docker/releases/tag/1.0.0 This is just a build of @agend07's fork. |
To make it work with Docker 19.03.6 on Debian 9.12, I had to build @agend07's fork with Go 1.13. Go 1.9 would not work. If anybody needs it, here is the compressed resulting binary |
Something went wrong after an update and I haven't dug into it too much since this project seems dead. Basically, systemd sees the
systemd-docker
executable as dying with a status code of 1, but the container is still running. I don't know if there's some mixup with Docker communication going on or if systemd changed somewhere to break it. I suspect Docker, but I have no evidence.The best solution seems to be migrating to
rkt
for running the images, but that is blocked by rkt/rkt#2392 without the ability to push images to a registry.The text was updated successfully, but these errors were encountered: