Coder Social home page Coder Social logo

systemd-docker's Introduction

This is based on github.com/ibuildthecloud/systemd-docker Please go to http://github.com/ibuildthecloud/systemd-docker for more info about it.

However - There is one important change in this. This no longer moves the cgroups (or) notifies the systemd of the PID of the container process. Instead I run the service as 'simple' systemd service. The systemd-docker will, in a loop, keep watching for the health of the container. If there is any error, it exits.

I also specify the ExecStartPre and ExecStop, ExecStopPost - to take care of any case where the container didnt stop/remove clearly.

Here is an example:

# more /usr/lib/systemd/system/my.service
[Unit]
Description=my test
After=docker.service
Requires=docker.service

[Service]
ExecStartPre=-/usr/bin/docker kill busybox
ExecStartPre=-/usr/bin/docker rm -f busybox
ExecStart=/usr/pensando/bin/systemd-docker run --name busybox --rm busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done"
ExecStop=/usr/bin/docker stop busybox
ExecStopPost=/usr/bin/docker rm -f busybox
Restart=always
RestartSec=10s
Type=simple
NotifyAccess=all
TimeoutStartSec=120
TimeoutStopSec=15

Why different from systemd-docker

While my production setup uses docker and runs the services with systemd, I wanted ability to unit-test my code. I started off with running the whole setup with docker (hence using docker in docker). However the cgroup treatment is really painful. A service running in docker in docker has very odd path in /proc/../cgroup which actually does not exist in the same path if mounting the file. Hence moving the container to systemd cgroup does not work.

Given such a case, my above solution seems to work for me. If you see any issues, please open an issue or send a pull-request.

License

Apache License, Version 2.0

systemd-docker's People

Contributors

ibuildthecloud avatar apatil avatar bcwaldon avatar nasuku avatar motiejus avatar emmetog avatar notti avatar jonboulle avatar marcelk avatar clehene avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.