Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Commit

Permalink
Add instructions for CoreOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Aug 7, 2014
1 parent 7425470 commit e7eea7c
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,35 @@ By default `systemd-docker` will send READY=1 to the systemd notification socket

What this will do is setup a bind mount for the notification socket and then set the NOTIFY_SOCKET environment variable. If you are going to use this feature of systemd take some time to understand the quirks of it. More info in this [mailing list thread](http://comments.gmane.org/gmane.comp.sysutils.systemd.devel/18649). In short, systemd-notify is not reliable because often the child dies before systemd has time to determine which cgroup it is a member of

Running on CoreOS
=================

If you are running on CoreOS, it may be more problematic to install `systemd-docker` to `/opt/bin`. To make this easier add the following line to your unit file.

`ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker`

That command will install systemd-docker to /opt/bin. The full nginx example that is above would now be as below.

```ini
[Unit]
Description=Nginx
After=docker.service
Requires=docker.service

[Service]
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker
ExecStart=/opt/bin/systemd-docker run --rm --name %n nginx
Restart=always
RestartSec=10s
Type=notify
NotifyAccess=all
TimeoutStartSec=120
TimeoutStopSec=15

[Install]
WantedBy=multi-user.target
```

License
-------
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
17 changes: 17 additions & 0 deletions example/coreos-nginx.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=Nginx
After=docker.service
Requires=docker.service

[Service]
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker
ExecStart=/opt/bin/systemd-docker run --rm --name %n nginx
Restart=always
RestartSec=10s
Type=notify
NotifyAccess=all
TimeoutStartSec=120
TimeoutStopSec=15

[Install]
WantedBy=multi-user.target
6 changes: 6 additions & 0 deletions image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM busybox:latest

ADD systemd-docker /
ADD startup.sh /
RUN mkdir -p /opt/bin
CMD ["/startup.sh"]
11 changes: 11 additions & 0 deletions image/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

checksum()
{
md5sum $1 | awk '{print $1}'
}

if [ ! -e /opt/bin/systemd-docker ] || [ "$(checksum /opt/bin/systemd-docker)" != "$(checksum /systemd-docker)" ]; then
echo "Installing systemd-docker to /opt/bin"
cp -pf /systemd-docker /opt/bin
fi

0 comments on commit e7eea7c

Please sign in to comment.