Commit Graph

50 Commits

Author SHA1 Message Date
4ee7be3ff1 upstart: Don't emit "started" event until docker.sock is available
Fixes #6647: Other upstart jobs that depend on docker by specifying
"start on started docker" would often start before the docker daemon was
ready, so they'd fail with "Cannot connect to the Docker daemon" or
"dial unix /var/run/docker.sock: no such file or directory".

This is because "docker -d" doesn't daemonize, it runs in the
foreground, so upstart can't know when the daemon is ready to receive
incoming connections. (Traditionally, a daemon will create all necessary
sockets and then fork to signal that it's ready; according to @tianon
this "isn't possible in Go"[1]. See also [2].)

Presumably this isn't a problem with systemd init with its socket
activation. The SysV init scripts may or may not suffer from this
problem but I have no motivation to fix them.

This commit adds a "post-start" stanza to the upstart configuration
that waits for the socket to be available. Upstart won't emit the
"started" event until the "post-start" script completes.[3]

Note that the system administrator might have specified a different path
for the socket, or a tcp socket instead, by customising
/etc/default/docker. In that case we don't try to figure out what the
new socket is, but at least we don't wait in vain for
/var/run/docker.sock to appear.

If the main script (`docker -d`) fails to start, the `initctl status
$UPSTART_JOB | grep -q "stop/"` line ensures that we don't loop forever.
I stole this idea from Steve Langasek.[4]

If for some reason we *still* end up in an infinite loop --I guess
`docker -d` must have hung-- then at least we'll be able to see the
"Waiting for /var/run/docker.sock" debug output in
/var/log/upstart/docker.log.

I considered using inotifywait instead of sleep, but it isn't worth
the complexity & the extra dependency.

[1] https://github.com/docker/docker/issues/6647#issuecomment-47001613
[2] https://code.google.com/p/go/issues/detail?id=227
[3] http://upstart.ubuntu.com/cookbook/#post-start
[4] https://lists.ubuntu.com/archives/upstart-devel/2013-April/002492.html

Signed-off-by: David Röthlisberger <david@rothlis.net>
Upstream-commit: f42c0a53a38a2a141bec8768d0836a3726de4a83
Component: engine
2014-12-16 21:25:01 +00:00
54a35eb340 Merge pull request #8198 from jfrazelle/add-jessie-to-various-maintainers
Adding self to various maintainers files.
Upstream-commit: f0327c99dd6fb7353d76726e0adb67a1b5a98451
Component: engine
2014-10-28 19:35:28 -07:00
4a5c5e00b6 Fix system socket/service unit files
Two problems how they are today:

In the current systemd unit files it is impossible to have the
docker.service started at system boot.  Instead enableing docker.service
will actually enable docker.socket.  This is a problem, as that means
any container with --restart=always will not launch on reboot.  And of
course as soon as you log in and type docker ps, docker.service will be
launched and now your images are running.  Talk about a PITA to debug!
The fix is to just install docker.service when people ask docker.service
to be enabled.  If an admin wants to enable docker.socket instead, that
is fine and will work just as it does today.

The second problem is a common docker devel workflow, although not
something normal admins would hit.  In this case consider a dev doing
the following:

systemctl stop docker.service

docker -d
[run commands]
[^C]

systemctl start docker.service

Running docker -d (without -F fd://) will clean up the
/var/run/docker.sock when it exits.  Remember, you just ran the docker
daemon not telling it about socket actviation, so cleaning up its socket
makes sense!  The new docker, started by systemd will expect socket
activation, but the last one cleaned up the docker.sock.  So things are
just broken.  You can, today, work around this by restarting
docker.socket.  This fixes it by telling docker.socket that it is
PartOf=docker.service.  So when docker.service is
started/stopped/restarted docker.socket will also be
started/stopped/restarted.  So the above semi-common devel workflow will
be fine.  When docker.service is stopped, so is docker.socket,   docker
-d (without -F fd://) will create and delete /var/run/docker.sock.
Starting docker.service again will restart docker.socket, which will
create the file an all is happy in the word.

Signed-off-by: Eric Paris <eparis@redhat.com>
Upstream-commit: 053c3557b3198466ecfbe066fefdbab2a78771d5
Component: engine
2014-10-07 14:09:08 -04:00
8734c910c3 Adding self to various maintainers files.
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
Upstream-commit: 6c60e8c7849742c111a2b0a5ad4ff88fc8e960ef
Component: engine
2014-09-29 15:43:07 -07:00
cfaf0bf98f Try to avoid issues when the Docker daemon restarts.
This change will allow the Docker daemon's init script to wait up to 5
minutes before being forcibly terminated by the initscript. Many
non-trivial containers will take more than the default 3 seconds to
stop, which can result in containers whose rootfs is still mounted and
will not restart when the daemon starts up again, or worse, orphan
processes that are still running.

Signed-off-by: Steven Merrill <steven.merrill@gmail.com>
Upstream-commit: 640d2ef6f54d96ac4fc3f0f745cb1e6a35148607
Component: engine
2014-09-18 08:21:00 -04:00
b1b3c2f243 Fix several minor issues with Debian sysvinit script
- add `set -e` to make failing commands bail the script
- remove trailing `exit 0` which is just extraneous anyhow
- adjust `status_of_proc` options to pass in `$DOCKER_DESC` so we get consistently styled messages like `Docker is running` or `Docker is not running` or `could not access PID file for Docker`

Signed-off-by: Andrew Page <admwiggin@gmail.com>
Upstream-commit: 478fdaf93353c70a26c0043dadb650fd2f101c40
Component: engine
2014-08-07 16:45:22 -06:00
4569bccd5e Systemd service should not restart on failure
This should not be done by default but used by adminsys with a drop-in.d file,
for buggy daemons which crash without known fixes.

Docker-DCO-1.1-Signed-off-by: Sébastien Luttringer <seblu@seblu.net> (github: seblu)
Upstream-commit: 533916fa6bb0b19fb887b5b0b2b704b224154b41
Component: engine
2014-07-28 11:50:24 +02:00
d687489711 Systemd .service should install .socket
And remove the WantedBy directive.

See: https://bugs.archlinux.org/task/41338

Docker-DCO-1.1-Signed-off-by: Sébastien Luttringer <seblu@seblu.net> (github: seblu)
Upstream-commit: 0f26195a8ddd0bde95865816576d827a9ed0727c
Component: engine
2014-07-28 00:18:14 +02:00
e1fb484158 Fix ordering in systemd service file
See: https://bugs.archlinux.org/task/41338

Docker-DCO-1.1-Signed-off-by: Sébastien Luttringer <seblu@seblu.net> (github: seblu)
Upstream-commit: fe68df36fc9c85ae30af9bf53a13e8af0534e613
Component: engine
2014-07-28 00:17:40 +02:00
6ae4c9014c update go import path and libcontainer
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
Upstream-commit: b3ee9ac74e171e00f14027e39278013629e681b8
Component: engine
2014-07-24 22:19:50 +00:00
554507d5b7 contrib/init/systemd: add philips as MAINTAINER
As requested after #7021 add me as a maintainer alongside the sword
toting @lsm5.

Docker-DCO-1.1-Signed-off-by: Brandon Philips <brandon.philips@coreos.com> (github: philips)
Upstream-commit: 81307680142d5ddd8e80c70c5da8afc799318556
Component: engine
2014-07-17 11:57:16 -07:00
927ac2785f systemd unitfile requires docker.socket
modified:   contrib/init/systemd/docker.service

Docker-DCO-1.1-Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org> (github: lsm5)
Upstream-commit: 0bde827c3f01fc5ae99eb0b93170e75c99cd5d77
Component: engine
2014-07-14 18:08:38 -05:00
e091331e86 use systemd socket-activation by default
modified:   contrib/init/systemd/docker.service
	renamed:    contrib/init/systemd/socket-activation/docker.socket -> contrib/init/systemd/docker.socket
	deleted:    contrib/init/systemd/socket-activation/docker.service

Docker-DCO-1.1-Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org> (github: lsm5)
Upstream-commit: 076ac1d7d212c3a81a401a2fba8b9965bc26df16
Component: engine
2014-07-14 17:41:07 -05:00
5901c9dd26 add systemd MAINTAINERS file
new file:   contrib/init/systemd/MAINTAINERS

Docker-DCO-1.1-Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org> (github: lsm5)
Upstream-commit: 5105981431def23a7424a0c0c09095d815243ea9
Component: engine
2014-07-14 17:38:23 -05:00
2226522e72 Add a conditional to contrib/init/sysvinit-debian/docker for Dash vs Bash support
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Upstream-commit: 4f0fbb885eb6b561fd6e4ba26b35cb30dd8d9121
Component: engine
2014-07-14 12:34:04 -06:00
9eda104cfe Fix the systemd socket activation socket permissions
Fixes #6836

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Upstream-commit: 3589f5b9c2d9e5cb6d057713aa8d591295c5f523
Component: engine
2014-07-07 08:09:25 -06:00
c8806a50df I'm going to wish I didn't do this
Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
Upstream-commit: fa29b1f062d25c1a8ca62f02b9cc7533df4c7449
Component: engine
2014-07-03 10:31:56 +10:00
a3d12bd8ea Add NOFILE and NPROC ulimit settings to the SysV init script
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Upstream-commit: bae79c3e7285c170f97a0f7f331a48fb47f0f40e
Component: engine
2014-07-02 09:38:19 -06:00
7c15233e4a Add NOFILE and NPROC ulimit settings to the OpenRC init script
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Upstream-commit: 7abe70c0b1018729006fd5d614ada2dc67edb9b2
Component: engine
2014-07-02 09:36:57 -06:00
801392d7a3 Make debian init work when called quickly.
We use the start-stop-daemon pid creation mechanism in addition the intrinsic built into docker.  This means the pid file is guaranteed to be written out by the time the script exits.

See #6184.

Docker-DCO-1.1-Signed-off-by: Joe Beda <joe.github@bedafamily.com> (github: jbeda)
Upstream-commit: c11fadb282ea7e96eef2280a5e422fd2c94e8c45
Component: engine
2014-06-03 16:57:32 -07:00
335a844d29 Ensure networking is up before starting docker
This resolves a problem that I have been having where docker starts before networking is up. See issue #5944 for more details.

Docker-DCO-1.1-Signed-off-by: Jeffrey Bolle <jeffreybolle@gmail.com> (github: jeffreybolle)
Upstream-commit: c52889db27a2af09ed7f6c92f2d6c6fd9737bf63
Component: engine
2014-05-24 19:03:11 +01:00
91009e208d Merge pull request #5844 from stpierre/init-script-wait-for-pidfile
Wait for pidfile to exist when starting with RedHat init script
Upstream-commit: 47aa9f5a0e38f395cee7517720f8a80587bb911b
Component: engine
2014-05-20 10:25:03 -06:00
cdfe67b94e contrib/init/upstart: start on local-filesystems
This changes the upstart init script to start on `local-filesystems`.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
Upstream-commit: ba0c8292917560b45f840f187c2a8f452550705d
Component: engine
2014-05-16 19:12:59 +03:00
d8d2d008c4 added timeout when waiting for docker pidfile
Docker-DCO-1.1-Signed-off-by: Chris St. Pierre <chris.a.st.pierre@gmail.com> (github: stpierre)
Upstream-commit: 1ee423bd5dd7abf6f5f4662132b77fdebf14529a
Component: engine
2014-05-16 09:36:54 -04:00
cdfc80841a Wait for pidfile to exist when starting with Redhat init script
Fixes #5359

Docker-DCO-1.1-Signed-off-by: Chris St. Pierre <chris.a.st.pierre@gmail.com> (github: stpierre)
Upstream-commit: a598dba1346c9f2e878e8250a9d641a2206cb4e5
Component: engine
2014-05-16 09:08:59 -04:00
a947a1c096 Add "Should-Start" cgroupfs-mount and cgroup-lite to sysvinit-debian init script
It's fine to list both here because "Should-Start" is a loose binding (ie, if the listed service exists, it'll be started first, but otherwise, this one will start without it).

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Upstream-commit: 36d913078b7ea0138dbc5d561703d068e7e31934
Component: engine
2014-05-07 09:46:41 -06:00
45a3d3da44 upstart: use exec here so upstart can monitor the process and not just a shell
Docker-DCO-1.1-Signed-off-by: Michael Gorsuch <michael.gorsuch@gmail.com> (github: gorsuch)
Upstream-commit: 73ee4879afd557a3ddd0740b0a281024060f2436
Component: engine
2014-03-27 12:44:33 -05:00
463aedf3de Add upstart nofile/noproc similar to systemd init
Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
Upstream-commit: e27c635c06dcad61ce7185d95debef9ef7c9f7e0
Component: engine
2014-03-18 16:27:20 -04:00
c48adc6929 Update to double-dash everywhere
These were found using `git grep -nE '[^-a-zA-Z0-9<>]-[a-zA-Z0-9]{2}'` (fair warning: _many_ false positives there).

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Upstream-commit: 44fe8cbbd174b5d85d4a063ed270f6b9d2279b70
Component: engine
2014-03-13 11:46:02 -06:00
b4c989ed6d Add variable for DOCKER_LOGFILE to sysvinit and use append instead of overwrite in opening the logfile
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Upstream-commit: 76dc670f413de64361a8bb3efa3381331e796b21
Component: engine
2014-03-11 01:40:31 -06:00
be15eebe0b Fix init script cgroup mounting workarounds to be more similar to cgroupfs-mount and thus work properly
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Upstream-commit: b21f8872cc684c95a2e30cec9f7c744a78a819f8
Component: engine
2014-03-11 01:39:06 -06:00
a185dfcddd Fix a few packaging bugs, including and especially a temporary patch to our upstart script to mount cgroups properly
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Upstream-commit: 50082f792be22b97dcc79afe666289ecefbc3864
Component: engine
2014-03-10 03:27:46 -06:00
ecc13ba924 bump open files and procs limit via unitfile
Docker-DCO-1.1-Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com> (github: lsm5)

	modified:   contrib/init/systemd/docker.service
	modified:   contrib/init/systemd/socket-activation/docker.service
Upstream-commit: 291d5e642e83ca84bd4f9b470eac8f840fecf48c
Component: engine
2014-03-04 22:29:51 -05:00
f734c53533 remove unneeded sysctl changes in sysvinit-redhat init script
Docker-DCO-1.1-Signed-off-by: Adam Miller <admiller@redhat.com> (github: maxamillion)
Upstream-commit: 4317011e21b4e4025a9c92c7dc255fbf62af573a
Component: engine
2014-02-13 12:11:38 -06:00
b2a134f727 Added sysvinit/sysconfig files for redhat family of distros (RHEL/CentOS/SL/etc.)
Docker-DCO-1.1-Signed-off-by: Adam Miller <admiller@redhat.com> (github: maxamillion)
Upstream-commit: 2222cba5acd3fe663d492d7bc3fd4787d4c9869f
Component: engine
2014-02-12 12:03:32 -06:00
0e8d28d6ec contrib: systemd: make socket-activation Restart=always
Do as was done to f09a78cd219b24d4308034c8dd13410cfe5fbec7 in the
socket-activation example.

Docker-DCO-1.1-Signed-off-by: Brandon Philips <brandon.philips@coreos.com> (github: philips)
Upstream-commit: 4dab34c2045b7bcc735227867126f0796cbb09c1
Component: engine
2014-01-29 17:42:32 -08:00
667c92d38b remove ip fowarding from systemd (fixed: commit #3801)
Docker-DCO-1.1-Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com> (github: lsm5)
Upstream-commit: a9d0bbcfc6e45817f39f15a7c9b11305b4c04bad
Component: engine
2014-01-29 11:06:23 -05:00
5e880285ec ExecStartPre commands updated
Docker-DCO-1.1-Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com> (github: lsm5)

systemd service no longer does '/bin/mount/ --make-rprivate /'.
Core issue fixed by Alex Larsson (commit 157d99a).

ip forwarding enabled.
Upstream-commit: f09a78cd219b24d4308034c8dd13410cfe5fbec7
Component: engine
2014-01-29 11:06:23 -05:00
e0523eee43 fix(contrib/init/systemd): remove mount rprivate
Docker does this now via 157d99a72786c454dfaad8b0800914cc80879aa8

Docker-DCO-1.1-Signed-off-by: Brandon Philips <brandon.philips@coreos.com> (github: philips)
Upstream-commit: 1f44921c51883e923ed82ed4e30eca6f79702cfb
Component: engine
2014-01-27 17:18:09 -08:00
7f4461fb98 Allow fd:// like unix:// and tcp://
Somthing like 20605eb310f0b57bd06eea80ec63c5022fc83bde

Docker-DCO-1.1-Signed-off-by: Brandon Philips <brandon.philips@coreos.com> (github: philips)
Upstream-commit: 7f9d3268bf0e1d4a79d07c67e22eb14d3de96f6c
Component: engine
2014-01-27 17:18:09 -08:00
93246312a1 server: add socket activation
This adds the ability to socket activate docker by passing in
`-H fd://*` along with examples systemd configuration files.

The fastest way to test this is to run:

```
/usr/lib/systemd/systemd-activate -l 127.0.0.1:2001 /usr/bin/docker -d -H 'fd://*'
docker -H tcp://127.0.0.1:2001 ps
```

Docker-DCO-1.1-Signed-off-by: Brandon Philips <brandon.philips@coreos.com> (github: philips)
Upstream-commit: 87fb2c973d8f9a8a1868ab0c2da504095d04715b
Component: engine
2014-01-27 17:17:07 -08:00
8a1ed2b1a2 Update systemd service file with suggestions from @seblu
Upstream-commit: 75e9cff98ce585ccd050a4014adb99d95509c9b7
Component: engine
2013-11-27 16:55:37 -07:00
6b9d5c5bd5 Merge pull request #2652 from tianon/upstart-defaults-too
Add /etc/default/docker support to upstart, too (mirroring sysvinit)
Upstream-commit: b94e9ed0de0817d07ad590e5d32262016f25e6e8
Component: engine
2013-11-13 10:42:41 -08:00
10393910ab Update upstart check in sysvinit to be exactly the same as the init_is_upstart function from /lib/lsb/init-functions (which isn't available in 12.04 or we'd use it directly)
Upstream-commit: 88edba7e86efc8d7e118a9863ab701f0b5493d62
Component: engine
2013-11-11 11:57:25 -07:00
97bc55ee5d Add /etc/default/docker support to upstart, too (mirroring sysvinit)
Upstream-commit: 7cf7dda87d59981f8a1727725f6d914dcc4c1815
Component: engine
2013-11-11 11:13:16 -07:00
60cd8ebc40 Fix sysvinit upstart detection and give it a pretty message
Upstream-commit: bb76157d240ae871bc3d9b6a945a982abf0473c7
Component: engine
2013-11-11 11:10:19 -07:00
4349b8fd0b Merge pull request #2365 from tianon/sysvinit-consistency
Update sysvinit script to fix a few inconsistencies and be more useful/correct downstream
Upstream-commit: 8ad46ef401fd0665efe16f50021a5a48a14b51e5
Component: engine
2013-11-04 15:34:51 -08:00
9053b11b66 fix(systemd): provide a better description
Fix-up the docker service file description to declare what the service is not what it does.

When a systemd machine starts up the Description of each unit scrolls by instead of the service's filename. Because the current description doesn't say what it is it isn't very friendly:

```
Oct 31 20:40:49 localhost systemd[1]: Started Update Engine.
Oct 31 20:40:49 localhost systemd[1]: Starting Multi-User System.
Oct 31 20:40:49 localhost systemd[1]: Reached target Multi-User System.
Oct 31 20:40:49 localhost systemd[1]: Starting Easily create lightweight, portable, self-sufficient containers from any application!...
Oct 31 20:40:49 localhost systemd[1]: Started Easily create lightweight, portable, self-sufficient containers from any application!.
```
Upstream-commit: 393562340c6f386a837eac9a616c456dc54faa4f
Component: engine
2013-10-31 14:41:49 -07:00
d9388b066c Update sysvinit script to fix a few inconsistencies and be more useful/correct downstream
Upstream-commit: 865649d7ac7e5ebb5b3debf65b626e96a88836b5
Component: engine
2013-10-28 14:08:21 -06:00
82851ecb8f Add initial init scripts library, including systemd, sysvinit, upstart, and openrc
Upstream-commit: c405d53b6e6658b1cbe9ad7ba52ea6dc9330f546
Component: engine
2013-10-17 12:03:49 -06:00