Page MenuHomeDevCentral

Systemd unit to start and stop Docker containers
ClosedPublic

Authored by Sandlayth on Jul 13 2015, 01:02.
Referenced Files
F2827773: D20.diff
Fri, Apr 19, 01:29
Unknown Object (File)
Thu, Apr 18, 00:45
Unknown Object (File)
Wed, Apr 17, 22:24
Unknown Object (File)
Mon, Apr 15, 05:08
Unknown Object (File)
Mon, Apr 15, 04:08
Unknown Object (File)
Mon, Apr 15, 03:29
Unknown Object (File)
Sun, Apr 14, 08:24
Unknown Object (File)
Sun, Apr 14, 06:20

Details

Summary

We currently have Docker containers without autostart functionality.

A systemd unit could be created to start and stop them, with Docker service as dependency.

Fixes T467.

Test Plan

Test the units on Dwellers.

Diff Detail

Repository
rOPS Nasqueron Operations
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Sandlayth retitled this revision from to Resolving T467.
Sandlayth updated this object.
Sandlayth edited the test plan for this revision. (Show Details)
Sandlayth added a reviewer: dereckson.
Sandlayth added subscribers: Sandlayth, dereckson.
dereckson retitled this revision from Resolving T467 to [WIP] Systemd unit to start and stop Docker containers.Jul 13 2015, 01:23
dereckson updated this object.
dereckson edited the test plan for this revision. (Show Details)

Let's try to be compliant with "docker-containers" name: docker-containers-start, docker-containers-stop ?

scripts/paas/docker/systemd/docker-containers.service
4 ↗(On Diff #44)

We should put both scripts at the same place, for example at /usr/local/bin/

Sandlayth edited edge metadata.
  • Salt infrastructure will be at the root
dereckson requested changes to this revision.Jul 13 2015, 17:38
dereckson edited edge metadata.
dereckson added inline comments.
paas/docker/systemd/docker-containers.service
4 ↗(On Diff #46)

We can put them both in the same directory. If it's not Systemd specific (if we could outside of Systemd run these scripts), maybe the ideal place is /usr/local/bin?

Any person in the docker group could control docker, so sbin isn't the ideal I imagine.

This revision now requires changes to proceed.Jul 13 2015, 17:38
Sandlayth edited edge metadata.

Executable are placed in a uniq directory.

Okay, with that, we'll need to put them to a known systemd path. That's convenient.

Green light to test in live.

Root access provided, see T494.

dereckson requested changes to this revision.Jul 15 2015, 10:34
dereckson edited edge metadata.
dereckson added inline comments.
paas/docker/systemd/docker-containers.service
4 ↗(On Diff #56)

Actually, systemd requires absolute path, not relative paths.

Jul 15 12:30:20 dwellers.nasqueron.org systemd[1]: [/usr/lib/systemd/system/docker-containers.service:4] Executable path is not absolute, ignoring: ...er_start
Jul 15 12:30:20 dwellers.nasqueron.org systemd[1]: [/usr/lib/systemd/system/docker-containers.service:5] Executable path is not absolute, ignoring: docker_stop
Jul 15 12:30:20 dwellers.nasqueron.org systemd[1]: docker-containers.service lacks ExecStart setting. Refusing.

Let's try this:

  • /usr/local/bin/docker-containers-start
  • /usr/local/bin/docker-containers-stop
This revision now requires changes to proceed.Jul 15 2015, 10:34

To be coherent with D102, files should be in roles/paas/docker/systemd-unit/files/

Sandlayth edited edge metadata.
Sandlayth marked an inline comment as done.

Systemd unit to start and stop Docker containers

Sandlayth edited edge metadata.

Systemd units to start and stop containers

  • Revising files hierarchy
dereckson requested changes to this revision.Dec 27 2015, 19:04
dereckson edited edge metadata.

This doesn't match our current set of containers launched:

$ docker ps | grep -v arcanist
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                                                                                                                                                                                              NAMES
4c98054578d3        jenkinsci/jenkins       "/bin/tini -- /usr/lo"   5 days ago          Up 5 days           0.0.0.0:50000->50000/tcp, 0.0.0.0:38080->8080/tcp                                                                                                                                                                  ci
fd356b7b01e9        nasqueron/rabbitmq      "/docker-entrypoint.s"   3 weeks ago         Up 2 weeks          0.0.0.0:1883->1883/tcp, 0.0.0.0:4369->4369/tcp, 0.0.0.0:5672->5672/tcp, 0.0.0.0:8883->8883/tcp, 0.0.0.0:15672->15672/tcp, 0.0.0.0:15674->15674/tcp, 0.0.0.0:25672->25672/tcp, 0.0.0.0:61613->61613/tcp, 5671/tcp   white-rabbit
ff7fc9e99559        nasqueron/cachet        "/usr/local/sbin/init"   3 weeks ago         Up 3 weeks          443/tcp, 0.0.0.0:39080->80/tcp                                                                                                                                                                                     cachet
e6add030d18c        local_discourse/forum   "/sbin/boot"             4 weeks ago         Up 4 weeks          0.0.0.0:32080->80/tcp                                                                                                                                                                                              forum
a02452eb7dad        nasqueron/etherpad      "/entrypoint.sh bin/r"   4 weeks ago         Up 3 weeks          0.0.0.0:34080->9001/tcp                                                                                                                                                                                            pad
330d032afb49        nasqueron/phabricator   "/usr/local/sbin/init"   4 weeks ago         Up 4 weeks          443/tcp, 0.0.0.0:35080->80/tcp                                                                                                                                                                                     wolfphab
b13a9f0390fe        nasqueron/aphlict       "node aphlict_server."   4 weeks ago         Up 4 weeks          0.0.0.0:22280-22281->22280-22281/tcp                                                                                                                                                                               aphlict
51099144b9cd        nasqueron/phabricator   "/usr/local/sbin/init"   4 weeks ago         Up 4 weeks          443/tcp, 0.0.0.0:31080->80/tcp                                                                                                                                                                                     devcentral
f96fae8dd5f2        nasqueron/mysql         "/entrypoint.sh mysql"   4 weeks ago         Up 4 weeks          3306/tcp                                                                                                                                                                                                           acquisitariat

Could we get a configuration file for this list?

This revision now requires changes to proceed.Dec 27 2015, 19:04

Files lost on this revision:

Sandlayth edited edge metadata.
  • Revising files hierarchy
  • Added files containers.conf and get-containers-list
Sandlayth edited edge metadata.
  • Revising files hierarchy
  • Added files containers.conf and get-containers-list
paas/docker/systemd-unit/files/docker_start
3

That will be docker start <words before \n> as command, the remaining will be new commands.

But xargs will work here: get-containers-list | xargs docker start

paas/docker/systemd-unit/files/docker_stop
3

reverse

paas/docker/systemd-unit/files/get-containers-list
4

reverse

23

reverse

  • Revising files hierarchy
  • Added files containers.conf and get-containers-list
  • Revising files hierarchy
  • Added files containers.conf and get-containers-list

Remove WIP from the title when it's ready to land.

dereckson retitled this revision from [WIP] Systemd unit to start and stop Docker containers to Systemd unit to start and stop Docker containers.Dec 28 2015, 17:39
dereckson requested changes to this revision.EditedDec 28 2015, 17:43
dereckson edited edge metadata.

Scripts and systemd OK.

Please also take care of this previous comment:

In D20#2040, @dereckson wrote:

This doesn't match our current set of containers launched:

$ docker ps | grep -v arcanist
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                                                                                                                                                                                              NAMES
4c98054578d3        jenkinsci/jenkins       "/bin/tini -- /usr/lo"   5 days ago          Up 5 days           0.0.0.0:50000->50000/tcp, 0.0.0.0:38080->8080/tcp                                                                                                                                                                  ci
fd356b7b01e9        nasqueron/rabbitmq      "/docker-entrypoint.s"   3 weeks ago         Up 2 weeks          0.0.0.0:1883->1883/tcp, 0.0.0.0:4369->4369/tcp, 0.0.0.0:5672->5672/tcp, 0.0.0.0:8883->8883/tcp, 0.0.0.0:15672->15672/tcp, 0.0.0.0:15674->15674/tcp, 0.0.0.0:25672->25672/tcp, 0.0.0.0:61613->61613/tcp, 5671/tcp   white-rabbit
ff7fc9e99559        nasqueron/cachet        "/usr/local/sbin/init"   3 weeks ago         Up 3 weeks          443/tcp, 0.0.0.0:39080->80/tcp                                                                                                                                                                                     cachet
e6add030d18c        local_discourse/forum   "/sbin/boot"             4 weeks ago         Up 4 weeks          0.0.0.0:32080->80/tcp                                                                                                                                                                                              forum
a02452eb7dad        nasqueron/etherpad      "/entrypoint.sh bin/r"   4 weeks ago         Up 3 weeks          0.0.0.0:34080->9001/tcp                                                                                                                                                                                            pad
330d032afb49        nasqueron/phabricator   "/usr/local/sbin/init"   4 weeks ago         Up 4 weeks          443/tcp, 0.0.0.0:35080->80/tcp                                                                                                                                                                                     wolfphab
b13a9f0390fe        nasqueron/aphlict       "node aphlict_server."   4 weeks ago         Up 4 weeks          0.0.0.0:22280-22281->22280-22281/tcp                                                                                                                                                                               aphlict
51099144b9cd        nasqueron/phabricator   "/usr/local/sbin/init"   4 weeks ago         Up 4 weeks          443/tcp, 0.0.0.0:31080->80/tcp                                                                                                                                                                                     devcentral
f96fae8dd5f2        nasqueron/mysql         "/entrypoint.sh mysql"   4 weeks ago         Up 4 weeks          3306/tcp                                                                                                                                                                                                           acquisitariat

Could we get a configuration file for this list?

This revision now requires changes to proceed.Dec 28 2015, 17:43
Sandlayth edited edge metadata.
  • Revising files hierarchy
  • Added files containers.conf and get-containers-list
  • Adding new containers to the list : cachet, ci, and white-rabbit
Sandlayth marked 3 inline comments as done.
Sandlayth edited edge metadata.
  • Revising files hierarchy
  • Added files containers.conf and get-containers-list
  • Adding new containers to the list : cachet, ci, and white-rabbit
dereckson edited edge metadata.

Looks good to me.

This revision is now accepted and ready to land.Dec 29 2015, 02:32
This revision was automatically updated to reflect the committed changes.