Commit graph

85 commits

Author SHA1 Message Date
Michael Crosby
d16737f971 Add "Delegate=yes" to docker's service file
We need to add delegate yes to docker's service file so that it can
manage the cgroups of the processes that it launches without systemd
interfering with them and moving the processes after it is reloaded.

```
       Delegate=
           Turns on delegation of further resource control partitioning to
           processes of the unit. For unprivileged services (i.e. those
           using the User= setting), this allows processes to create a
           subhierarchy beneath its control group path. For privileged
           services and scopes, this ensures the processes will have all
           control group controllers enabled.
```

This is the proper fix for issue #20152

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-25 10:32:09 -08:00
Jessica Frazelle
6241250824
remove tasksmax, people on newer kernels can add it themselves
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2016-02-09 14:07:23 -08:00
Jess Frazelle
d47812dd1d Merge pull request #19886 from AndrewGuenther/185160-init-socket-fix
Wait to fire start event until socket is created
2016-02-03 17:38:52 -08:00
Vincent Woo
87a450a37f Allow disabling of colored Docker logs via daemon flag.
Signed-off-by: Vincent Woo <me@vincentwoo.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-02-01 16:19:18 -05:00
Andrew Guenther
9f401254bd Wait to fire start event until socket is created
Previously, this check only worked if no host was specified and was
hard coded to check for "/var/run/docker.sock"

This change generalizes that check and captures any specified socket
and waits for it to be created.

Caveat: This will only check the first socket specified, but it is an
improvement over none at all.

Fixes #185160

Signed-off-by: Andrew Guenther <guenther.andrew.j@gmail.com>
2016-02-01 08:40:26 -08:00
Tianon Gravi
90e33640b8 Add a note to /etc/default/docker noting that it does not apply to systemd
Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
2016-01-22 07:35:02 -08:00
Candid Dauth
105778343a Set TasksMax in addition to LimitNPROC in systemd service files
systemd sets an additional limit on processes and threads that defaults to 512 when run under Linux >= 4.3.
See more information here: http://unix.stackexchange.com/a/255603/59955

Signed-off-by: Candid Dauth <cdauth@cdauth.eu>
2016-01-16 18:45:41 +01:00
oyld
bbbc01b86e Fix syntax error in init script
Signed-off-by: oyld <oyld0210@163.com>
2015-12-22 04:00:00 -08:00
Tonis Tiigi
eff5e6498f Disable timeout for systemd
With content addressability update starting upgraded
daemon for the first time can take a long time if
graph dir was not prepared with a migration tool before.
This avoids systemd timeouts while the migration is
taking place.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2015-12-03 13:15:31 -08:00
Julien Pervillé
6f83dd22a3 Update upstart init script to start on filesystem (not only on local ones).
Signed-off-by: Julien Pervillé <julien.perville@perfect-memory.com>
2015-11-05 20:38:52 +01:00
Ewa Czechowska
5c94a9e800 #16560 Add timeout to sudo service docker stop on sysvinit
Add 10 seconds timeout when running `sudo service docker stop`. This is
especially needed when running `sudo service docker restart`. Otherwise,
`restart` results in exitstatus 1, because `start` has nothing to do.

Signed-off-by: Ewa Czechowska <ewa@ai-traders.com>
2015-09-24 19:41:32 +00:00
Matthias Rampke
01c5cfcc56 Do not try to guess "docker" in Debian SysV init script
On boot, the init script is invoked from `/etc/rcN.d/S20docker` (where N
is the runlevel). Consequently, the init script tried to find the
defaults at `/etc/defaults/S20docker` and the binary at
`/usr/bin/S20docker`. This causes the docker daemon to fail at boot with
the error

    /usr/bin/S20docker not present or not executable

Starting it manually works because it invokes `/etc/init.d/docker` which
has the correct basename.

Fix this by hardcoding "docker" as the base name.

Signed-off-by: Matthias Rampke <mr@soundcloud.com>
2015-09-23 11:27:34 +00:00
William Hubbs
e3772538c0 Fix OpenRC init script
The shebang for OpenRC init scripts is now #!/sbin/openrc-run, and we
can also use the default start and stop functions built into OpenRC.

Signed-off-by: William Hubbs <w.d.hubbs@gmail.com>
2015-08-25 12:02:01 -05:00
William Hubbs
1c0c68b18f Drop execute bit from openrc init script
Signed-off-by: William Hubbs <w.d.hubbs@gmail.com>
2015-08-25 12:00:54 -05:00
Jessie Frazelle
ebe27cb34c Merge pull request #14868 from jeffminard-ck/rhel-init-detect-failure
Allow RHEL init script to detect daemon start pid failure
2015-08-24 14:24:36 -07:00
Rob Vesse
f8387f6904 Fix silent failure in RedHat sysvinit script
The docker script in contrib/init/sysvinit-redhat will fail silently on
a start if Docker is not installed in the default /usr/bin/ location.
While a non-zero exit code is returned the user will receive no visible
indication (i.e. error message) as to why Docker was not started.

This commit changes the logic so that in the case that the docker
executable is not found in the expected location or the user does not
have execute permissions on the executable appropriate error messages
are now shown to the user as well as exiting with a non-zero exit code

Signed-off-by: Rob Vesse <rvesse@dotnetrdf.org>
2015-08-06 12:07:38 +01:00
Dimitri John Ledkov
d3e5179c29 systemd: set service type to notify.
Currently the service type is 'simple', the default, meaning that
docker.service is considered to be started straight after
spawning. This is incorrect as there is significant amount of time
between spawning and docker ready to accept connections on the passed
sockets. Docker does implement systemd socket activate and
notification protocol, and send the ready signal to systemd, once it
is ready. However for systemd to take those notifications into
account, the service file type should be set to notify.

Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
2015-07-29 14:02:12 +01:00
Jeff Minard
6f8fdb8aa8 Allow RHEL init script to detect daemon start pid failure
If you have some kind of bogus `other_args` in `/etc/sysconfig/docker` the start script will report "started" but it's full of lies. This enhances the flow so that if the pidfile never shows up (failure to start) you get a proper failure message.

I also added dots for fun.

Signed-off-by: Jeff Minard <jeff.minard@creditkarma.com>
2015-07-22 11:36:34 -07:00
David Calavera
346ce4f8d2 Update init scripts to use docker daemon.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-07-22 11:24:38 -07:00
David Calavera
d8592eaff8 Revert "contrib/init: unshare mount namespace for inits"
This reverts commit b6569b6b82.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-06-15 10:35:17 -07:00
Eric-Olivier Lamey
dbf5e36fd6 Fix docs URL in systemd service file.
Fixes #13799.

Signed-off-by: Eric-Olivier Lamey <eo@lamey.me>
2015-06-08 10:21:43 +00:00
David Calavera
0256bbdebb Merge pull request #13039 from stevenbrichards/13031-Upstart
Fix check for upstart not detecting properly
2015-05-28 10:38:55 -07:00
Steven Richards
e5ff643aed Fixes #13031 - Check for upstart or init is not detecting properly
This will now properly check whether /etc/init.d/docker or service docker is
invoking the script and respond to the user accordingly.

Signed-off-by: Steven Richards <steven@axiomzen.co>
2015-05-28 09:52:05 -07:00
David Xia
2f9e7a067a Increase upstart kill timeout to 20 seconds
Give Docker more time to kill containers before upstart kills Docker.
The default kill timeout is 5 seconds.
This will help decrease the chance of but not eliminate the chance of
orphaned container processes.

Signed-off-by: David Xia <dxia@spotify.com>
2015-05-20 14:20:46 -04:00
Vincent Batts
b6569b6b82 contrib/init: unshare mount namespace for inits
* openrc
* sysvinit-debian
* upstart

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2015-04-23 14:08:37 -04:00
Lewis Marshall
302e3834a0 Prevent Upstart post-start stanza from hanging
Once the job has failed and is respawned, the status becomes `docker
respawn/post-start` after subsequent failures (as opposed to `docker
stop/post-start`), so the post-start script needs to take this into
account.

I could not find specific documentation on the job transitioning to the
`respawn/post-start` state, but this was observed on Ubuntu 14.04.2.

Signed-off-by: Lewis Marshall <lewis@lmars.net>
2015-03-31 01:56:16 +01:00
Vincent Batts
7617ec176d .: remove trailing white spaces
blame tibor this one ;-)
```
find . -type f -not -name '*.png' -not -name '*.go' -not -name '*.md'
-not -name '*.tar' -not -name '*.pem' -not -path './vendor/*' -not -path
'./.git/*' -not -path '*/testdata/*' -not -path './docs/*images*' -not
-path '*/testfiles/*' -not -path './bundles/*' -not -path
'./docs/*static*/*' -not -path './docs/*article-img/*' -exec grep -HnEl
'[[:space:]]$' {} \; | xargs sed -iE 's/[[:space:]]*$//'
```

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2015-03-25 13:38:17 -04:00
Tibor Vass
0252ad0adc Revert "Dealing with trailing whitespaces"
The validation script from #10681 is too pedantic, and does not handle
well situations like:

```
cat <<EOF   # or <<-EOF
	Whether the leading whitespace is stripped out or not by bash
	it should still be considered as valid.
EOF
```

This reverts commit 4e65c1c319.

Signed-off-by: Tibor Vass <tibor@docker.com>
2015-03-25 10:04:56 -06:00
André Martins
4e65c1c319 Dealing with trailing whitespaces
Created a validation that detects all trailing whitespaces from every
text file that isn't *.go, *.md, vendor/*,
docs/theme/mkdocs/tipuesearch*

Removed trailing whitespaces from every text file except from vendor/*
builder/parser/testfiles*, docs/theme/mkdocs/tipuesearch* and *.md

Signed-off-by: André Martins <martins@noironetworks.com>
2015-03-17 03:34:01 +00:00
Arnaud Porterie
89bdaa35e0 Remove subdirectories MAINTAINERS files
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
2015-03-06 18:21:51 -08:00
Jessie Frazelle
9944f8b954 Merge pull request #10598 from lsm5/core-file-size
no limit on core size
2015-02-09 17:31:40 -08:00
Lokesh Mandvekar
ae9cdbbde7 no limit on core size
set LimitCORE=infinity to ensure complete core creation,
allows extraction of as much information as possible.

Thanks to Ulrich Obergfell <uobergfe@redhat.com>
and Jeremy Eder <jeder@redhat.com>

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2015-02-09 19:04:50 +00:00
Mike Leone
05d04843e6 Fixing stale pidfile issue when docker dies abruptly
Signed-off-by: Mike Leone <mleone896@gmail.com>

fixing indent

Signed-off-by: Mike Leone <mleone896@gmail.com>
2015-02-09 14:01:12 -05:00
Vincent Batts
6bb6586458 contrib/sysvinit-redhat: unshare mount namespace
unshare the mount namespace of the docker daemon to avoid other pids
outside the daemon holding mount references of docker containers.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2015-01-20 16:00:41 -05:00
Vincent Batts
eb76cb2301 contrib/systemd: mount namespace and subtree flags
This systemd.exec setting will construct a new mount namespace for the
docker daemon, and use slave shared-subtree mounts so that volume mounts
propogate correctly into containers.

By having an unshared mount namespace for the daemon it ensures that
mount references are not held by other pids outside of the docker
daemon. Frequently this can be seen in EBUSY or "device or resource
busy" errors.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
2015-01-20 14:22:04 -05:00
David Röthlisberger
f42c0a53a3 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>
2014-12-16 21:25:01 +00:00
Solomon Hykes
f0327c99dd Merge pull request #8198 from jfrazelle/add-jessie-to-various-maintainers
Adding self to various maintainers files.
2014-10-28 19:35:28 -07:00
Eric Paris
053c3557b3 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>
2014-10-07 14:09:08 -04:00
Jessica Frazelle
6c60e8c784 Adding self to various maintainers files.
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-09-29 15:43:07 -07:00
Steven Merrill
640d2ef6f5 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>
2014-09-18 08:21:00 -04:00
Tianon Gravi
478fdaf933 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>
2014-08-07 16:45:22 -06:00
Sébastien Luttringer
533916fa6b 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)
2014-07-28 11:50:24 +02:00
Sébastien Luttringer
0f26195a8d 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)
2014-07-28 00:18:14 +02:00
Sébastien Luttringer
fe68df36fc 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)
2014-07-28 00:17:40 +02:00
Victor Vieux
b3ee9ac74e update go import path and libcontainer
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
2014-07-24 22:19:50 +00:00
Brandon Philips
8130768014 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)
2014-07-17 11:57:16 -07:00
Lokesh Mandvekar
0bde827c3f 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)
2014-07-14 18:08:38 -05:00
Lokesh Mandvekar
076ac1d7d2 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)
2014-07-14 17:41:07 -05:00
Lokesh Mandvekar
5105981431 add systemd MAINTAINERS file
new file:   contrib/init/systemd/MAINTAINERS

Docker-DCO-1.1-Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org> (github: lsm5)
2014-07-14 17:38:23 -05:00
Tianon Gravi
4f0fbb885e 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)
2014-07-14 12:34:04 -06:00