Commit graph

445 commits

Author SHA1 Message Date
Daniel Nephin
c502bcff33 Remove unnecessary getLayerInit
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-14 11:59:10 -05:00
Tianon Gravi
3a633a712c
Merge pull request #36194 from dnephin/add-canonical-import
Add canonical import path
2018-02-07 13:06:45 -08:00
Daniel Nephin
4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00
Dennis Chen
44b074d199 Daemon: passdown the --oom-kill-disable option to containerd
Current implementaion of docke daemon doesn't pass down the
`--oom-kill-disable` option specified by the end user to the containerd
when spawning a new docker instance with help from `runc` component, which
results in the `--oom-kill-disable` doesn't work no matter the flag is `true`
or `false`.

This PR will fix this issue reported by #36090

Signed-off-by: Dennis Chen <dennis.chen@arm.com>
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2018-02-05 03:25:59 +00:00
Brian Goff
a510192b86 Set daemon root to use shared propagation
This change sets an explicit mount propagation for the daemon root.
This is useful for people who need to bind mount the docker daemon root
into a container.

Since bind mounting the daemon root should only ever happen with at
least `rlsave` propagation (to prevent the container from holding
references to mounts making it impossible for the daemon to clean up its
resources), we should make sure the user is actually able to this.

Most modern systems have shared root (`/`) propagation by default
already, however there are some cases where this may not be so
(e.g. potentially docker-in-docker scenarios, but also other cases).
So this just gives the daemon a little more control here and provides
a more uniform experience across different systems.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2018-01-23 14:17:08 -08:00
Sebastiaan van Stijn
6121a8429b
Move reload-related functions to reload.go
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-01-21 00:55:49 +01:00
John Howard
ce8e529e18 LCOW: Re-coalesce stores
Signed-off-by: John Howard <jhoward@microsoft.com>

The re-coalesces the daemon stores which were split as part of the
original LCOW implementation.

This is part of the work discussed in https://github.com/moby/moby/issues/34617,
in particular see the document linked to in that issue.
2018-01-18 08:29:19 -08:00
Sebastiaan van Stijn
b4a6313969
Golint: remove redundant ifs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-01-15 00:42:25 +01:00
Sebastiaan van Stijn
16fe5a1289
Remove unused experimental code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-12-18 17:07:48 +01:00
Kir Kolyshkin
516010e92d Simplify/fix MkdirAll usage
This subtle bug keeps lurking in because error checking for `Mkdir()`
and `MkdirAll()` is slightly different wrt to `EEXIST`/`IsExist`:

 - for `Mkdir()`, `IsExist` error should (usually) be ignored
   (unless you want to make sure directory was not there before)
   as it means "the destination directory was already there"

 - for `MkdirAll()`, `IsExist` error should NEVER be ignored.

Mostly, this commit just removes ignoring the IsExist error, as it
should not be ignored.

Also, there are a couple of cases then IsExist is handled as
"directory already exist" which is wrong. As a result, some code
that never worked as intended is now removed.

NOTE that `idtools.MkdirAndChown()` behaves like `os.MkdirAll()`
rather than `os.Mkdir()` -- so its description is amended accordingly,
and its usage is handled as such (i.e. IsExist error is not ignored).

For more details, a quote from my runc commit 6f82d4b (July 2015):

    TL;DR: check for IsExist(err) after a failed MkdirAll() is both
    redundant and wrong -- so two reasons to remove it.

    Quoting MkdirAll documentation:

    > MkdirAll creates a directory named path, along with any necessary
    > parents, and returns nil, or else returns an error. If path
    > is already a directory, MkdirAll does nothing and returns nil.

    This means two things:

    1. If a directory to be created already exists, no error is
    returned.

    2. If the error returned is IsExist (EEXIST), it means there exists
    a non-directory with the same name as MkdirAll need to use for
    directory. Example: we want to MkdirAll("a/b"), but file "a"
    (or "a/b") already exists, so MkdirAll fails.

    The above is a theory, based on quoted documentation and my UNIX
    knowledge.

    3. In practice, though, current MkdirAll implementation [1] returns
    ENOTDIR in most of cases described in #2, with the exception when
    there is a race between MkdirAll and someone else creating the
    last component of MkdirAll argument as a file. In this very case
    MkdirAll() will indeed return EEXIST.

    Because of #1, IsExist check after MkdirAll is not needed.

    Because of #2 and #3, ignoring IsExist error is just plain wrong,
    as directory we require is not created. It's cleaner to report
    the error now.

    Note this error is all over the tree, I guess due to copy-paste,
    or trying to follow the same usage pattern as for Mkdir(),
    or some not quite correct examples on the Internet.

    [1] https://github.com/golang/go/blob/f9ed2f75/src/os/path.go

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-11-27 17:32:12 -08:00
Kenfe-Mickael Laventure
ddae20c032
Update libcontainerd to use containerd 1.0
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-10-20 07:11:37 -07:00
Brian Goff
c6a2044497 Don't abort when setting may_detach_mounts
83c2152de5 sets the kernel param for
fs.may_detach_mounts, but this is not neccessary for the daemon to
operate. Instead of erroring out (and thus aborting startup) just log
the error.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-10-11 14:54:24 -04:00
Brian Goff
83c2152de5 Automatically set may_detach_mounts=1 on startup
This is kernel config available in RHEL7.4 based kernels that enables
mountpoint removal where the mountpoint exists in other namespaces.
In particular this is important for making this pattern work:

```
umount -l /some/path
rm -r /some/path
```

Where `/some/path` exists in another mount namespace.
Setting this value will prevent `device or resource busy` errors when
attempting to the removal of `/some/path` in the example.

This setting is the default, and non-configurable, on upstream kernels
since 3.15.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-09-20 09:57:25 -04:00
Victor Vieux
a5f9783c93 Merge pull request #34252 from Microsoft/akagup/lcow-remotefs-sandbox
LCOW: Support for docker cp, ADD/COPY on build
2017-09-15 16:49:48 -07:00
Simon Ferquel
e89b6e8c2d Volume refactoring for LCOW
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
2017-09-14 12:33:31 -07:00
Akash Gupta
7a7357dae1 LCOW: Implemented support for docker cp + build
This enables docker cp and ADD/COPY docker build support for LCOW.
Originally, the graphdriver.Get() interface returned a local path
to the container root filesystem. This does not work for LCOW, so
the Get() method now returns an interface that LCOW implements to
support copying to and from the container.

Signed-off-by: Akash Gupta <akagup@microsoft.com>
2017-09-14 12:07:52 -07:00
Yong Tang
70214f95b2 Merge pull request #34352 from ChenMin46/fix_rename_shared_namespace
Use ID rather than Name to identify a container when sharing namespace
2017-08-25 09:39:58 -07:00
Chen Min
b6e5ea8e57 Use ID rather than Name to identify a container when sharing namespace
Fix: https://github.com/moby/moby/issues/34307

Signed-off-by: Chen Min <chenmin46@huawei.com>
2017-08-25 01:55:50 +08:00
Kenfe-Mickael Laventure
45d85c9913
Update containerd to 06b9cb35161009dcb7123345749fef02f7cea8e0
This also update:
 - runc to 3f2f8b84a77f73d38244dd690525642a72156c64
 - runtime-specs to v1.0.0

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-21 12:04:07 -07:00
Daniel Nephin
9b47b7b151 Fix golint errors.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-18 14:23:44 -04:00
Brian Goff
ebcb7d6b40 Remove string checking in API error handling
Use strongly typed errors to set HTTP status codes.
Error interfaces are defined in the api/errors package and errors
returned from controllers are checked against these interfaces.

Errors can be wraeped in a pkg/errors.Causer, as long as somewhere in the
line of causes one of the interfaces is implemented. The special error
interfaces take precedence over Causer, meaning if both Causer and one
of the new error interfaces are implemented, the Causer is not
traversed.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-08-15 16:01:11 -04:00
Kir Kolyshkin
7120976d74 Implement none, private, and shareable ipc modes
Since the commit d88fe447df ("Add support for sharing /dev/shm/ and
/dev/mqueue between containers") container's /dev/shm is mounted on the
host first, then bind-mounted inside the container. This is done that
way in order to be able to share this container's IPC namespace
(and the /dev/shm mount point) with another container.

Unfortunately, this functionality breaks container checkpoint/restore
(even if IPC is not shared). Since /dev/shm is an external mount, its
contents is not saved by `criu checkpoint`, and so upon restore any
application that tries to access data under /dev/shm is severily
disappointed (which usually results in a fatal crash).

This commit solves the issue by introducing new IPC modes for containers
(in addition to 'host' and 'container:ID'). The new modes are:

 - 'shareable':	enables sharing this container's IPC with others
		(this used to be the implicit default);

 - 'private':	disables sharing this container's IPC.

In 'private' mode, container's /dev/shm is truly mounted inside the
container, without any bind-mounting from the host, which solves the
issue.

While at it, let's also implement 'none' mode. The motivation, as
eloquently put by Justin Cormack, is:

> I wondered a while back about having a none shm mode, as currently it is
> not possible to have a totally unwriteable container as there is always
> a /dev/shm writeable mount. It is a bit of a niche case (and clearly
> should never be allowed to be daemon default) but it would be trivial to
> add now so maybe we should...

...so here's yet yet another mode:

 - 'none':	no /dev/shm mount inside the container (though it still
		has its own private IPC namespace).

Now, to ultimately solve the abovementioned checkpoint/restore issue, we'd
need to make 'private' the default mode, but unfortunately it breaks the
backward compatibility. So, let's make the default container IPC mode
per-daemon configurable (with the built-in default set to 'shareable'
for now). The default can be changed either via a daemon CLI option
(--default-shm-mode) or a daemon.json configuration file parameter
of the same name.

Note one can only set either 'shareable' or 'private' IPC modes as a
daemon default (i.e. in this context 'host', 'container', or 'none'
do not make much sense).

Some other changes this patch introduces are:

1. A mount for /dev/shm is added to default OCI Linux spec.

2. IpcMode.Valid() is simplified to remove duplicated code that parsed
   'container:ID' form. Note the old version used to check that ID does
   not contain a semicolon -- this is no longer the case (tests are
   modified accordingly). The motivation is we should either do a
   proper check for container ID validity, or don't check it at all
   (since it is checked in other places anyway). I chose the latter.

3. IpcMode.Container() is modified to not return container ID if the
   mode value does not start with "container:", unifying the check to
   be the same as in IpcMode.IsContainer().

3. IPC mode unit tests (runconfig/hostconfig_test.go) are modified
   to add checks for newly added values.

[v2: addressed review at https://github.com/moby/moby/pull/34087#pullrequestreview-51345997]
[v3: addressed review at https://github.com/moby/moby/pull/34087#pullrequestreview-53902833]
[v4: addressed the case of upgrading from older daemon, in this case
     container.HostConfig.IpcMode is unset and this is valid]
[v5: document old and new IpcMode values in api/swagger.yaml]
[v6: add the 'none' mode, changelog entry to docs/api/version-history.md]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2017-08-14 10:50:39 +03:00
Yong Tang
7ccd8bda77 Merge pull request #33722 from TomSweeneyRedHat/tsweeney/privmessage
Add clarification to --privileged error message
2017-08-09 16:08:10 -07:00
Derek McGowan
1009e6a40b
Update logrus to v1.0.1
Fixes case sensitivity issue

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-31 13:16:46 -07:00
Tobias Klauser
01f70b028e Switch Stat syscalls to x/sys/unix
Switch some more usage of the Stat function and the Stat_t type from the
syscall package to golang.org/x/sys. Those were missing in PR #33399.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-07-27 10:09:02 +02:00
Yuanhong Peng
4a6cbf9bcb Return an empty stats if "container not found"
If we get "container not found" error from containerd, it's possibly
because that this container has already been stopped. It will be ok to
ignore this error and just return an empty stats.

Signed-off-by: Yuanhong Peng <pengyuanhong@huawei.com>
2017-07-10 16:30:48 +08:00
Michael Crosby
9d87e6e0fb Do not set -1 for swappiness
Do not set a default value for swappiness as the default value should be
`nil`

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-03 11:23:15 -07:00
TomSweeneyRedHat
38e26f0d8d Add clarification to --privileged error message
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2017-06-25 14:02:20 -04:00
Fabio Kung
a43be3431e avoid re-reading json files when copying containers
Signed-off-by: Fabio Kung <fabio.kung@gmail.com>
2017-06-23 07:52:34 -07:00
John Howard
3aa4a00715 LCOW: Move daemon stores to per platform
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-06-20 19:49:52 -07:00
Daniel Nephin
09cd96c5ad Partial refactor of UID/GID usage to use a unified struct.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-06-07 11:44:33 -04:00
Michael Crosby
005506d36c Update moby to runc and oci 1.0 runtime final rc
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-05 13:45:45 -07:00
Antonio Murdaca
abbbf91498
Switch to using opencontainers/selinux for selinux bindings
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-04-24 21:29:47 +02:00
Vincent Demeester
b0235fd515 Merge pull request #31827 from erikstmartin/master
Add mount point to cgroup root when initializing cgroup paths for cpu.rt_runtime
2017-04-03 22:39:49 +02:00
Daniel J Walsh
881e20ee0b If caller specifies label overrides, don't override security options
If a caller specifies an SELinux type or MCS Label and still wants to
share an IPC Namespace or the host namespace, we should allow them.
Currently we are ignoring the label specification if ipcmod=container
or pidmode=host.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-03-16 20:33:37 -04:00
Erik St. Martin
40e075532a Add mount point to cgroup root when initializing cgroup paths for
cpu.rt_runtime

PR https://github.com/docker/docker/pull/23430 introduced a couple more
flags including `--cpu-rt-runtime` to the docker daemon. It appears
recent changes or merge issues may have broken this. It currently does
not take the cgroup mount point into account when determining the cgroup
files to write values to. This breaks docker setting its own
`cpu.rt_runtime` for the daemon. This also means containers aren't able
to set theirs.

Also, the cgroups.FindCgroupMountpointAndRoot returns back a mount point
that includes the cgroup of the currently running container when docker
is run inside a docker container. this breaks the `--cpu-rt-runtime`
flag when running docker in docker. A fix has been placed here, but
potentially could be pulled up into libcontainer if this is a better
place for it.

Signed-off-by: Erik St. Martin <alakriti@gmail.com>
2017-03-14 16:18:36 -04:00
Vincent Demeester
f7819fcb25
Refactor cpu-realtime file creation to remove duplication
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-02-28 11:12:06 +01:00
Victor Vieux
cf5fe9ed0b Merge pull request #31075 from vieux/switch_to_new_versioning_scheme
Switch to new versioning scheme
2017-02-17 15:43:28 -08:00
Daniel Zhang
d7fda019bb Add daemon flag to set no_new_priv as default for unprivileged containers.
Signed-off-by: Daniel Zhang <jmzwcn@gmail.com>
2017-02-16 19:05:14 +08:00
Victor Vieux
47396d6377 Switch to new versioning scheme
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
2017-02-15 23:22:50 -08:00
allencloud
75f5d63ec8 rewrite reload code
Signed-off-by: allencloud <allen.sun@daocloud.io>
2017-02-15 21:57:27 +08:00
Vincent Demeester
db63f9370e
Extract daemon configuration and discovery to their own package
This also moves some cli specific in `cmd/dockerd` as it does not
really belong to the `daemon/config` package.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-02-08 09:53:38 +01:00
Vincent Demeester
354bd4aadd Merge pull request #29692 from yongtang/29492-daemon-shm-size
Add daemon option `--default-shm-size`
2017-02-01 16:56:10 +01:00
Alexander Morozov
ebaf1ced72 Merge pull request #27071 from rhvgoyal/docker-overlay-error
Warn if kernel does not support overlay with selinux
2017-01-31 13:41:02 -08:00
Yong Tang
db575ef626 Add daemon option --default-shm-size
This fix fixes issue raised in 29492 where it was not
possible to specify a default `--default-shm-size` in daemon
configuration for each `docker run``.

The flag `--default-shm-size` which is reloadable, has been
added to the daemon configuation.
Related docs has been updated.

This fix fixes 29492.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-01-27 12:17:06 -08:00
Alexander Morozov
cd6a61f1b1 Merge pull request #29887 from vdemeester/daemon-extract-stats-collector
Extract daemon statsCollector to its own package
2017-01-27 10:28:03 -08:00
Akihiro Suda
4a8799dc0a validate mount path for tmpfs
There was no validation for `docker run --tmpfs foo`.

In this PR, only two obvious rules are implemented:
 - path must be absolute
 - path must not be "/"
We should add more rules carefully.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-01-20 06:01:48 +00:00
Daehyeok Mun
6306019d0b Refactoring ineffectual assignments
This patch fixed below 4 types of code line
1. Remove unnecessary variable assignment
2. Use variables declaration instead of explicit initial zero value
3. Change variable name to underbar when variable not used
4. Add erro check and return for ignored error

Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
2017-01-13 00:27:01 -07:00
Sebastiaan van Stijn
f285d5b3e8
do not create init-dir if not needed
commit 56f77d5ade
added support for cpu-rt-period and cpu-rt-runtime,
but always initialized the cgroup path, even if not
used.

As a result, containers failed to start on a
read-only filesystem.

This patch only creates the cgroup path if
one of these options is set.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-01-09 15:28:51 +01:00
Vincent Demeester
835971c6fd
Extract daemon statsCollector to its own package
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-01-04 18:18:30 +01:00
Sebastiaan van Stijn
1dd9410776 Merge pull request #29683 from vdemeester/runconfig-clean
Clean some stuff from runconfig that are cli only…
2016-12-29 17:42:08 +01:00
allencloud
6fb05778ba fix nits in comments
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-12-27 23:30:50 +08:00
Vincent Demeester
c424be21b7
Clean some stuff from runconfig that are cli only…
… or could be in `opts` package. Having `runconfig/opts` and `opts`
doesn't really make sense and make it difficult to know where to put
some code.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-12-24 13:16:00 +01:00
Tonis Tiigi
3d86b0c79b Implement content addressability for plugins
Move plugins to shared distribution stack with images.

Create immutable plugin config that matches schema2 requirements.

Ensure data being pushed is same as pulled/created.

Store distribution artifacts in a blobstore.

Run init layer setup for every plugin start.

Fix breakouts from unsafe file accesses.

Add support for `docker plugin install --alias`

Uses normalized references for default names to avoid collisions when using default hosts/tags.

Some refactoring of the plugin manager to support the change, like removing the singleton manager and adding manager config struct.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2016-12-23 13:29:58 -08:00
Doug Davis
ff42a2eb41 Only show global warnings once
Upon each container create I'm seeing these warning **every** time in the
daemon output:
```
WARN[0002] Your kernel does not support swap memory limit
WARN[0002] Your kernel does not support cgroup rt period
WARN[0002] Your kernel does not support cgroup rt runtime
```
Showing them for each container.create() fills up the logs and encourages
people to ignore the output being generated - which means its less likely
they'll see real issues when they happen.  In short, I don't think we
need to show these warnings more than once, so let's only show these
warnings at daemon start-up time.

Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-11-30 10:11:42 -08:00
Antonio Murdaca
30b8712e93
daemon: remove not needed unmarshal
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-11-23 12:53:25 +01:00
Brian Goff
06e92cc2c1 Merge pull request #28577 from chchliang/defercode
function setupOOMScoreAdj file close illogicality
2016-11-18 11:48:58 -05:00
chchliang
e82fa89bcd function setupOOMScoreAdj file close illogicality
Signed-off-by: chchliang <chen.chuanliang@zte.com.cn>
2016-11-18 17:34:01 +08:00
Michael Crosby
aff99136b4 Fix cfs period calculation
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-11-18 00:47:43 -08:00
Yong Tang
d22ac2f3a0 Fix error messages for --cpus from daemon
This fix fixes error messages for `--cpus` from daemon.

When `docker run` takes `--cpus`, it will translate into NanoCPUs
and pass the value to daemon. The `NanoCPU` is not visible to the user.
The error message generated from daemon used 'NanoCPU' which may cause
some confusion to the user.

This fix fixes this issue by returning the error in CPUs instead.

This fix fixes 28456.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-11-15 17:16:09 -08:00
Yong Tang
846baf1fd3 Add --cpus flag to control cpu resources
This fix tries to address the proposal raised in 27921 and add
`--cpus` flag for `docker run/create`.

Basically, `--cpus` will allow user to specify a number (possibly partial)
about how many CPUs the container will use. For example, on a 2-CPU system
`--cpus 1.5` means the container will take 75% (1.5/2) of the CPU share.

This fix adds a `NanoCPUs` field to `HostConfig` since swarmkit alreay
have a concept of NanoCPUs for tasks. The `--cpus` flag will translate
the number into reused `NanoCPUs` to be consistent.

This fix adds integration tests to cover the changes.

Related docs (`docker run` and Remote APIs) have been updated.

This fix fixes 27921.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-11-04 09:43:10 -07:00
Justin Cormack
efa5e85cf7 Merge pull request #26276 from runcom/seccomp-conf
daemon: add a flag to override the default seccomp profile
2016-11-04 15:45:30 +00:00
Mrunal Patel
4c10c2ded3 Ensure that SELinux Options are set when seccomp is already set
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2016-11-03 13:23:53 -07:00
Justin Cormack
81683e898a Merge pull request #27599 from estesp/getent-path
Add support for looking up user/groups via `getent`
2016-11-03 15:11:42 +00:00
Antonio Murdaca
b237189e6c
daemon: add a flag to override the default seccomp profile
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-11-02 21:41:29 +01:00
Michael Crosby
74bdacb908 Merge pull request #27953 from thaJeztah/fix-deprecation-version
Update deprecation versions for "email" and colon in "security options"
2016-11-01 14:31:32 -07:00
Alexander Morozov
bf16fa47b7 Merge pull request #27929 from daehyeok/logrus_refactoring
Fix logrus formatting
2016-11-01 11:12:46 -07:00
Sebastiaan van Stijn
e41a39dbae
Update deprecation versions for "email" and colon in "security options"
These features were originally scheduled
for removal in docker 1.13, but we changed
our deprecation policy to keep features
for three releases instead of two.

This updates the deprecation version
to match the deprecation policy.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-11-01 09:12:27 -07:00
Daehyeok Mun
fa710e504b Fix logrus formatting
This fix tries to fix logrus formatting by removing `f` from
`logrus.[Error|Warn|Debug|Fatal|Panic|Info]f` when formatting string
is not present.

Fixed issue #23459

Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
2016-10-31 22:05:01 -06:00
Yanqiang Miao
a9b6319e67 Optimized the indentation of codes and fix two typos
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
2016-11-01 10:35:18 +08:00
Phil Estes
6cb8392be9 Add support for looking up user/groups via getent
When processing the --userns-remap flag, add the
capability to call out to `getent` if the user and
group information is not found via local file
parsing code already in libcontainer/user.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2016-10-28 19:06:07 -04:00
Yong Tang
e9c4c513d1 Fix issue for --fixed-cidr when bridge has multiple addresses
This fix tries to address the issue raised in 26341
where multiple addresses in a bridge may cause `--fixed-cidr`
to not have the correct addresses.

The issue is that `netutils.ElectInterfaceAddresses(bridgeName)`
only returns the first IPv4 address.

This fix (together with the PR created in libnetwork )
changes `ElectInterfaceAddresses()` and `addresses()`
so that all IPv4 addresses are returned. This will allow the
possibility of selectively choose the address needed.

In `daemon_unix.go`, bridge address is chosen by comparing with
the `--fixed-cidr` first, thus resolve the issue in 26341.

This fix is tested manually, as is described in 26341:
```
brctl addbr cbr0
ip addr add 10.111.111.111/20 dev cbr0 label cbr0:main
ip addr add 10.222.222.222/12 dev cbr0 label cbr0:docker
ip link set cbr0 up
docker daemon --bridge=cbr0 --iptables=false --ip-masq=false --fixed-cidr=10.222.222.222/24
docker run --rm busybox ip route get 8.8.8.8 | grep -Po 'src.*'
src 10.222.222.0
```

This fix fixes 26341.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-26 20:11:29 -07:00
Erik St. Martin
56f77d5ade Implementing support for --cpu-rt-period and --cpu-rt-runtime so that
containers may specify these cgroup values at runtime. This will allow
processes to change their priority to real-time within the container
when CONFIG_RT_GROUP_SCHED is enabled in the kernel. See #22380.

Also added sanity checks for the new --cpu-rt-runtime and --cpu-rt-period
flags to ensure that that the kernel supports these features and that
runtime is not greater than period.

Daemon will support a --cpu-rt-runtime flag to initialize the parent
cgroup on startup, this prevents the administrator from alotting runtime
to docker after each restart.

There are additional checks that could be added but maybe too far? Check
parent cgroups to ensure values are <= parent, inspecting rtprio ulimit
and issuing a warning.

Signed-off-by: Erik St. Martin <alakriti@gmail.com>
2016-10-26 11:33:06 -04:00
Yong Tang
40f25809ab Fix an incorrect WARNING output in docker run/create
This fix tries to fix an incorrect `WARNING` output in `docker run/create`:
```
ubuntu@ubuntu:~/docker$ docker run -d --cpu-percent 80 busybox top
WARNING: %s does not support CPU percent. Percent discarded.
WARNING: linux
e963d1108e455e7f8f57626ca1305b5f1999e46025d2865b9a21fc8abc51a546
```

The reason was that in `daemon/daemon_unix.go`, the warning string
was not combined with `fmt.Sprintf` before appended to the output.

This fix fixes this issue.

This fix has been manually tested and verified:
```
ubuntu@ubuntu:~/docker$ docker run -d --cpu-percent 80 busybox top
WARNING: linux does not support CPU percent. Percent discarded.
fcf53f79d389235bae846d3d40804834659ac025edbc0d075ed91841a8e4c740
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-16 17:11:39 -07:00
Anusha Ragunathan
c5393ee147 Make authorization plugins use pluginv2.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-10-11 13:09:28 -07:00
Justin Cormack
d316e172da Merge pull request #26690 from mwhudson/ignore-oom_score_adj-failure
Ignore failure to set oom_score_adj, as happens in an unprivileged container.
2016-10-11 10:01:22 +01:00
Tõnis Tiigi
2945f902bd Merge pull request #27259 from LK4D4/no_map_pointers
daemon: do not use pointers to map
2016-10-10 13:15:03 -07:00
Alexander Morozov
44c280afbf daemon: do not use pointers to map
Also, do not shadow err with :=

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-10-10 11:37:36 -07:00
Vincent Demeester
91312f71aa Merge pull request #26882 from runcom/proxy-path
Specify userland proxy path
2016-10-07 09:44:39 +02:00
Antonio Murdaca
dd2e1947dc
daemon: add --userland-proxy-path flag
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-10-06 17:31:53 +02:00
Vivek Goyal
885b29df09 Warn if kernel does not support overlay/overlay2 with selinux
We first added error to not allow overlay with selinux enabled. Then later
we removed it as kernel was getting close to get the support. But this 
means user does not get meaningful message on old kernels.

This patch introduces a warning (Instead of error). Difference is that it
dynamically tries to detect if underlying kernel supports overlayfs with
selinux or not. And if it does not, it warns.

It will not warn if it detects that kernel supports overlayfs with selinux.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2016-10-04 15:35:56 -04:00
Vincent Demeester
694ba71e36 Merge pull request #26989 from aboch/none
Respect --bridge=none
2016-10-04 16:25:39 +02:00
Alessandro Boch
a0af884d3a Respect --bridge=none
- Do not create the default "bridge" network
- Get rid of the docker0 bridge

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-10-03 11:08:34 -07:00
Anusha Ragunathan
a00940f02c Initialize libnetwork and IPAMDriver with pluginstore.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-10-03 10:40:05 -07:00
Vivek Goyal
2508ca000e layer_store: Use CreateReadWrite() for -init layer instead of Create()
init layer is read/write layer and not read only layer. Following commit
introduced new graph driver method CreateReadWrite.

ef5bfad Adding readOnly parameter to graphdriver Create method

So far only windows seem to be differentiating between above two methods.
Making this change to make sure -init layer calls right method so that
we don't have surprises in future.

Windows does not need init layer. This patch also gets rid of creation of
init layer on windows.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2016-09-21 14:45:25 -04:00
Michael Hudson-Doyle
9ed54d3c67 add log messages when write to oom_score_adj fails
Signed-off-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-09-21 19:36:36 +12:00
Michael Hudson-Doyle
32f24bc3c5 Ignore failure to set oom_score_adj, as happens in an unprivileged container.
Signed-off-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-09-19 14:27:10 +12:00
Phil Estes
6062ae5742
Remove --read-only restriction when user ns enabled
The restriction is no longer necessary given changes at the runc layer
related to mount options of the rootfs. Also cleaned up the docs on
restrictions left for userns enabled mode. Re-enabled tests related to
--read-only when testing a userns-enabled daemon in integration-cli.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-09-09 13:23:41 -04:00
Brian Goff
b1dfefc4bb Merge pull request #26205 from allencloud/fix-warnings-append
add warnings when verifying container settings
2016-09-08 12:10:37 -04:00
Michael Crosby
91e197d614 Add engine-api types to docker
This moves the types for the `engine-api` repo to the existing types
package.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-09-07 11:05:58 -07:00
Michael Crosby
b42ab41b8f Merge pull request #25616 from rhatdan/overlay_selinux
Linux upstream kernel Overlay file systems support SELinux
2016-08-31 09:25:20 -07:00
allencloud
28b291dfda add warnings when verify setting
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-09-01 00:23:56 +08:00
Antonio Murdaca
7f88fca48e
daemon: ensure systemd cgroup is passed down to runtimes
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-08-26 15:33:26 +02:00
Phil Estes
43a1df6be2
Don't start daemon in userns mode if graphdir inaccessible
Warn the user and fail daemon start if the graphdir path has any
elements which will deny access to the remapped root uid/gid.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2016-08-24 11:25:30 -04:00
Michael Crosby
041e5a21dc Replace old oci specs import with runtime-specs
Fixes #25804

The upstream repo changed the import paths.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-08-17 09:38:34 -07:00
Mrunal Patel
3c3d2bf852 Allow using --pid=host and --net=host when --userns=host
It is safe to set other namespaces to host when user ns is set to host

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2016-08-16 14:16:14 -07:00
Dan Walsh
b71cd179fa Linux upstream kernel Overlay file systems support SELinux
Remove checks that prevent overlay and SELinux from working together.
Fixes are arriving in the 4.9 kernel.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2016-08-11 11:40:19 -04:00
Qiang Huang
da5d66fb70 Fix TestUpdateKernelMemoryUninitialized on new kernel version
Fixes: #25073

Update kernel memory on running containers without initialized
is forbidden only on kernel version older than 4.6.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-08-02 13:17:20 +08:00
Christy Perez
846f33f93d More accurate cgroup error messages
A kernel may support any of these, but an admin may have unmounted
certain cgroups, so let's include that possibility in the error so
as to avoid users thinking they have a kernel issue.

Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>
2016-07-29 09:50:50 -05:00
Alexander Morozov
ca43efb40e Merge pull request #24502 from allencloud/change-comparison-log-in-container-config
update comparison log in container config
2016-07-28 16:51:11 -07:00
Kenfe-Mickael Laventure
29b2714580 Vendor in new containerd
This version introduces the following:
 - uses nanosecond timestamps for event
 - ensure events are sent once their effect is "live"

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-07-18 11:44:24 -07:00
allencloud
e5bed17574 update comparison log in container config
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-07-16 11:26:19 +08:00
Michael Crosby
a894aec8d8 Add --oom-score-adjust to daemon
This adds an `--oom-score-adjust` flag to the daemon so that the value
provided can be set for the docker daemon's process.  The default value
for the flag is -500.  This will allow the docker daemon to have a
less chance of being killed before containers do.  The default value for
processes is 0 with a min/max of -1000/1000.

-500 is a good middle ground because it is less than the default for
most processes and still not -1000 which basically means never kill this
process in an OOM condition on the host machine.  The only processes on
my machine that have a score less than -500 are dbus at -900 and sshd
and xfce( my window manager ) at -1000.  I don't think docker should be
set lower, by default, than dbus or sshd so that is why I chose -500.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-07-12 15:53:15 -07:00
John Howard
b215c4c974 Merge pull request #24427 from swernli/remove_custom_images
Removing Custom Images support
2016-07-11 14:01:41 -07:00
Antonio Murdaca
59162641cc daemon: ensure we set default options to stock runtime
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-07-08 15:58:06 +02:00
Stefan J. Wernli
3e109f349f Removing Custom Images support
Now that Windows base images can be loaded directly into docker via "docker load" of a specialized tar file (with docker pull support on the horizon) we no longer have need of the custom images code path that loads images from a shared central location.  Removing that code and it's call points.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
2016-07-07 14:56:37 -07:00
Kenfe-Mickael Laventure
69af7d0d13 Use "docker-runc" as alias for the default runtime
This also moves the variable holding the default runtime name from the
engine-api repository into docker repository

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-06-22 11:59:26 -07:00
Lei Jitang
ecffb6d58c Daemon to support network restore
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-06-14 16:45:25 -07:00
Kenfe-Mickael Laventure
7b2e5216b8 Add support for multiples runtimes
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-06-14 07:47:31 -07:00
Yong Tang
d917723331 Fix incorrect usage of logrus when formatting string is present
This fix tries to fix logrus formatting by adding `f` to the end of
`logrus.[Error|Warn|Debug|Fatal|Panic|Info](` when formatting string
is present but the function `logrus.[Error|Warn|Debug|Fatal|Panic|Info](`
is used (incorrectly).

This fix is related to #23459, and is a follow up of #23461.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-06-11 15:37:36 -07:00
Antonio Murdaca
44ccbb317c *: fix logrus.Warn[f]
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-06-11 19:42:38 +02:00
Dan Walsh
c3dd6074b0 Multiple fixes for SELinux labels.
SELinux labeling should be disabled when using --privileged mode

/etc/hosts, /etc/resolv.conf, /etc/hostname should not be relabeled if they
are volume mounted into the container.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2016-05-25 16:11:02 -04:00
Sebastiaan van Stijn
27f34593ea
Suppress "IPv4 forwarding" warning for --net=none
There's no need to warn that "ip-forwarding" is disabled
if a container doesn't use networking.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-05-20 17:57:29 +02:00
Sebastiaan van Stijn
5fb7f9b29e
Suppress "IPv4 forwarding" warning for --net=host
Containers using the host network stack (--net=host)
are not affected by "ip-forwarding" being disabled,
so there's not need to show a warning.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-05-18 20:10:31 +02:00
Alessandro Boch
6eb2b903a3 Docker changes for libnetwork vendoring b66c038
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-16 15:04:01 -07:00
Wen Cheng Ma
c52a373bc8 update link comments
Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
2016-05-09 14:12:28 +08:00
Tonis Tiigi
668f0a2a4c Simplify blkio resources setup in spec
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-04-29 13:39:04 -07:00
Darren Stahl
8df2066341 Add IO Resource Controls for Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-04-25 13:07:29 -07:00
Kai Qiang Wu(Kennan)
62cb06a6c1 Make cpu validation correct
There was an error in validation logic before, should use period
instead of quota, and also add check for negative
number here, if not with that, it would had cpu.cfs_period_us: invalid argument
which is not good for users.

Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com>
2016-04-22 01:18:03 +00:00
Sebastiaan van Stijn
51b23d8842
Produce fatal error when running on kernel < 3.10.0
Running on kernel versions older than 3.10 has not been
supported for a while (as it's known to be unstable).

With the containerd integration, this has become more
apparent, because kernels < 3.4 don't support PR_SET_CHILD_SUBREAPER,
which is required for containerd-shim to run.

Change the previous "warning" to a "fatal" error, so
that we refuse to start.

There's still an escape-hatch for users by setting
"DOCKER_NOWARN_KERNEL_VERSION=1" so that they can
run "at their own risk".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-04-15 14:33:56 +02:00
Vincent Demeester
172ca1ca8c Merge pull request #20924 from Microsoft/10662-CPUResourceControls
Add CPU count and maximum resource controls for Windows
2016-04-15 08:14:59 +02:00
Darren Stahl
ea8c690886 Add CPU count and maximum resource controls for Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-04-14 15:40:25 -07:00
Rodolfo Carvalho
fee7e7c7a3 Fix a typo in hostConfig.ShmSize validation
Other places referring to the same configuration, including docs, have
the correct spelling.

Signed-off-by: Rodolfo Carvalho <rhcarvalho@gmail.com>
2016-04-12 16:45:05 +02:00
Vincent Demeester
a01f4dc229 Merge pull request #21853 from coolljt0725/fix_stats
Fix docker stats missing mem limit
2016-04-09 13:46:58 +02:00
Lei Jitang
a0a6d031d7 Fix docker stats missing memory limit
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-04-07 22:09:07 -04:00
Qiang Huang
50a6181005 Add minimum limit for memory reservation
Kernel has no limit for memory reservation, but in different
kernel versions, the default behavior is different.

On kernel 3.13,
docker run --rm --memory-reservation 1k busybox cat /sys/fs/cgroup/memory/memory.soft_limit_in_bytes
the output would be 4096, but on kernel 4.1, the output is 0.

Since we have minimum limit for memory and kernel memory, we
can have this limit for memory reservation as well, to make
the behavior consistent.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-04-06 09:37:51 +08:00
Anusha Ragunathan
7ed3d265a4 When using systemd, pass expected cgroupsPath and cli options to runc.
runc expects a systemd cgroupsPath to be in slice:scopePrefix:containerName
format and the "--systemd-cgroup" option to be set. Update docker accordingly.

Fixes 21475

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-03-29 14:20:10 -07:00
Sebastiaan van Stijn
f3d824771a Merge pull request #21487 from tonistiigi/fix-old-dind
Fix setting cgroup permission to user/privileged devices
2016-03-24 22:56:39 -07:00
Tonis Tiigi
8784bd6fde Fix wrong variable name on blkio resources
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-03-24 14:16:40 -07:00
Sebastiaan van Stijn
f2847f8ab3 Merge pull request #21315 from hqhq/hq_check_quota
Add validation for cpu period and quota
2016-03-24 14:10:48 -07:00
allencloud
25c9bd81f6 fix typos in daemon_unix.go
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-03-24 23:57:11 +08:00
Tibor Vass
694b32df51 Merge pull request #21370 from tonistiigi/expose-layer-ids
Expose RootFS in image inspect
2016-03-22 20:33:18 -04:00
Tibor Vass
3ce494f48c Merge pull request #21367 from mlaventure/containerd-docs-cleanup
Remove unneeded references to execDriver
2016-03-22 19:40:27 -04:00
Tonis Tiigi
14dc4a7158 Expose RootFS in image inspect
Fixes #20451

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-03-22 13:49:30 -07:00
Phil Estes
2b278f4846 Allow net and IPC namespaces to be shared when userns=on
Now that the namespace sharing code via runc is vendored with the
containerd changes, we can disable the restrictions on container to
container net and IPC namespace sharing when the daemon has user
namespaces enabled.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-03-21 22:20:26 -04:00
Qiang Huang
aae4bcf773 Remove dot in suffix to avoid double dot error message
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-03-22 09:17:54 +08:00
Qiang Huang
b041fdc0d5 Add validation for cpu period and quota
Accoding to:
https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt

It has minimal and maximal limit.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-03-22 09:17:54 +08:00
Kenfe-Mickael Laventure
8af4f89cba Remove unneeded references to execDriver
This includes:
 - updating the docs
 - removing dangling variables

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-03-21 13:06:08 -07:00
Jess Frazelle
b77573f48e Merge pull request #21274 from jfrazelle/fix-variables-that-werent-being-used
fix variables that werent being called
2016-03-18 18:03:15 -07:00
Jess Frazelle
e5a3f86e44 Merge pull request #20662 from tonistiigi/containerd-integration
Containerd integration
2016-03-18 17:21:18 -07:00
Tonis Tiigi
9c4570a958 Replace execdrivers with containerd implementation
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-03-18 13:38:32 -07:00
Jessica Frazelle
0e025b4bb1
fix variables that werent being called
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2016-03-17 13:19:55 -07:00
David Calavera
cb9aeb0413 Consolidate security options to use = as separator.
All other options we have use `=` as separator, labels,
log configurations, graph configurations and so on.
We should be consistent and use `=` for the security
options too.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-03-17 13:34:42 -04:00
Aleksa Sarai
e91ca0e239 daemon: use 0711 for /var/lib/docker
This fixes problems encountered when running with a remapped root (the
syscalls related to the metadata directory will fail under user
namespaces). Using 0711 rather than 0701 (which solved the problem
previously) fixes the issue.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-03-16 19:24:03 +11:00
Liron Levin
6993e891d1 Run privileged containers when userns are specified
Following #19995 and #17409 this PR enables skipping userns re-mapping
when creating a container (or when executing a command). Thus, enabling
privileged containers running side by side with userns remapped
containers.

The feature is enabled by specifying ```--userns:host```, which will not
remapped the user if userns are applied. If this flag is not specified,
the existing behavior (which blocks specific privileged operation)
remains.

Signed-off-by: Liron Levin <liron@twistlock.com>
2016-03-14 17:09:25 +02:00
msabansal
e8026d8a98 Windows libnetwork integration
Signed-off-by: msabansal <sabansal@microsoft.com>
2016-03-09 20:33:21 -08:00
David Calavera
dd32445ecc Merge pull request #18697 from jfrazelle/pids-cgroup
Add PIDs cgroup support to Docker
2016-03-08 14:03:36 -08:00
Jessica Frazelle
69cf03700f
pids limit support
update bash commpletion for pids limit

update check config for kernel

add docs for pids limit

add pids stats

add stats to docker client

Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2016-03-08 07:55:01 -08:00
Mrunal Patel
74bb1ce9e9 Add support for NoNewPrivileges in docker
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Add tests for no-new-privileges

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

Update documentation for no-new-privileges

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2016-03-07 09:47:02 -08:00
Qiang Huang
ca89c329b9 Add CgroupDriver to docker info
Fixes: #19539

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-03-02 20:07:06 +08:00
David Calavera
a793564b25 Remove static errors from errors package.
Moving all strings to the errors package wasn't a good idea after all.

Our custom implementation of Go errors predates everything that's nice
and good about working with errors in Go. Take as an example what we
have to do to get an error message:

```go
func GetErrorMessage(err error) string {
	switch err.(type) {
	case errcode.Error:
		e, _ := err.(errcode.Error)
		return e.Message

	case errcode.ErrorCode:
		ec, _ := err.(errcode.ErrorCode)
		return ec.Message()

	default:
		return err.Error()
	}
}
```

This goes against every good practice for Go development. The language already provides a simple, intuitive and standard way to get error messages, that is calling the `Error()` method from an error. Reinventing the error interface is a mistake.

Our custom implementation also makes very hard to reason about errors, another nice thing about Go. I found several (>10) error declarations that we don't use anywhere. This is a clear sign about how little we know about the errors we return. I also found several error usages where the number of arguments was different than the parameters declared in the error, another clear example of how difficult is to reason about errors.

Moreover, our custom implementation didn't really make easier for people to return custom HTTP status code depending on the errors. Again, it's hard to reason about when to set custom codes and how. Take an example what we have to do to extract the message and status code from an error before returning a response from the API:

```go
	switch err.(type) {
	case errcode.ErrorCode:
		daError, _ := err.(errcode.ErrorCode)
		statusCode = daError.Descriptor().HTTPStatusCode
		errMsg = daError.Message()

	case errcode.Error:
		// For reference, if you're looking for a particular error
		// then you can do something like :
		//   import ( derr "github.com/docker/docker/errors" )
		//   if daError.ErrorCode() == derr.ErrorCodeNoSuchContainer { ... }

		daError, _ := err.(errcode.Error)
		statusCode = daError.ErrorCode().Descriptor().HTTPStatusCode
		errMsg = daError.Message

	default:
		// This part of will be removed once we've
		// converted everything over to use the errcode package

		// FIXME: this is brittle and should not be necessary.
		// If we need to differentiate between different possible error types,
		// we should create appropriate error types with clearly defined meaning
		errStr := strings.ToLower(err.Error())
		for keyword, status := range map[string]int{
			"not found":             http.StatusNotFound,
			"no such":               http.StatusNotFound,
			"bad parameter":         http.StatusBadRequest,
			"conflict":              http.StatusConflict,
			"impossible":            http.StatusNotAcceptable,
			"wrong login/password":  http.StatusUnauthorized,
			"hasn't been activated": http.StatusForbidden,
		} {
			if strings.Contains(errStr, keyword) {
				statusCode = status
				break
			}
		}
	}
```

You can notice two things in that code:

1. We have to explain how errors work, because our implementation goes against how easy to use Go errors are.
2. At no moment we arrived to remove that `switch` statement that was the original reason to use our custom implementation.

This change removes all our status errors from the errors package and puts them back in their specific contexts.
IT puts the messages back with their contexts. That way, we know right away when errors used and how to generate their messages.
It uses custom interfaces to reason about errors. Errors that need to response with a custom status code MUST implementent this simple interface:

```go
type errorWithStatus interface {
	HTTPErrorStatusCode() int
}
```

This interface is very straightforward to implement. It also preserves Go errors real behavior, getting the message is as simple as using the `Error()` method.

I included helper functions to generate errors that use custom status code in `errors/errors.go`.

By doing this, we remove the hard dependency we have eeverywhere to our custom errors package. Yes, you can use it as a helper to generate error, but it's still very easy to generate errors without it.

Please, read this fantastic blog post about errors in Go: http://dave.cheney.net/2014/12/24/inspecting-errors

Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-02-26 15:49:09 -05:00
Qiang Huang
8ae6f6ac28 Support update swap memory only
We should support update swap memory without memory.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-02-24 13:36:47 +08:00
Aidan Hobson Sayers
dfb00652aa Expose bridge IPv6 setting to docker network inspect
Signed-off-by: Aidan Hobson Sayers <aidanhs@cantab.net>
2016-02-11 22:13:47 +00:00
Liron Levin
858f852da4 user namespaces: duplicate dot in user namespaces error message
duplicate dot in user namespaces error message:

$ docker run -ti --net=host ubuntu /bin/bash
docker: Error response from daemon: Cannot share the host or a
container's network namespace when user namespaces are enabled..

Signed-off-by: Liron Levin <liron@twistlock.com>
2016-02-03 16:56:34 +02:00
Antonio Murdaca
140a74347d daemon_unix: set golang runtime max threads
SetMaxThreads from runtime/debug in Golang is called to set max threads
value to 90% of /proc/sys/kernel/threads-max

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-01-30 21:37:24 +01:00
Aleksa Sarai
4357ed4a73 *: purge dockerinit from source code
dockerinit has been around for a very long time. It was originally used
as a way for us to do configuration for LXC containers once the
container had started. LXC is no longer supported, and /.dockerinit has
been dead code for quite a while. This removes all code and references
in code to dockerinit.

Signed-off-by: Aleksa Sarai <asarai@suse.com>
2016-01-26 23:47:02 +11:00
Vincent Demeester
141a301dca Merge pull request #19154 from hqhq/hq_verify_cgroupparent
Verify cgroup-parent name for systemd cgroup
2016-01-26 11:44:31 +01:00
David Calavera
c539be8833 Allow network configuration via daemon config file.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-01-25 18:54:56 -05:00
Qiang Huang
5ce5a8e966 Verify cgroup-parent name for systemd cgroup
Fixes: #17126

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-01-22 21:17:23 -05:00
Alexander Morozov
22ebeede30 Reuse *sysinfo.SysInfo instance in verification
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-01-20 17:08:10 -08:00
David Calavera
9c30492e9e Merge pull request #19311 from estesp/no-oom-warning-when-cant-even
Only warn on OOMKill disable if the feature is actually requested
2016-01-13 13:43:37 -08:00
Phil Estes
5a707d94d6 Only warn on OOMKill disable if the feature is actually requested
Instead of warning the caller who is disabling OOM killer that the
feature isn't available, only warn if they are trying to **enable** OOM
killer and it can't be done.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-01-13 11:53:44 -08:00
Alexander Morozov
7ea65da7ef Merge pull request #19254 from aboch/v6b
Account docker0 IPv6 address on daemon start
2016-01-13 09:48:41 -08:00
Qiang Huang
7b616d4743 Do not fail if not support OomKillDisable
Fixes: #19278

The issue seems existed since we add support for OomKillDisable,
OomKillDisable support should not be hard request, we just
discard it if not support and move on.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-01-13 09:07:40 +08:00
Madhu Venugopal
e221b8a3d6 Support --link for user-defined networks
This brings in the container-local alias functionality for containers
connected to u ser-defined networks.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-01-12 13:38:48 -08:00
Qiang Huang
f4a687334b Change OomKillDisable to be pointer
It's like `MemorySwappiness`, the default value has specific
meaning (default false means enable oom kill).

We need to change it to pointer so we can update it after
container is created.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
(cherry picked from commit 9c2ea42329)

Conflicts:
	vendor/src/github.com/docker/engine-api/types/container/host_config.go
2016-01-12 13:19:17 -05:00
Sebastiaan van Stijn
c72be040bb Merge pull request #19187 from estesp/lets-do-this
User namespaces: graduate from experimental
2016-01-12 09:34:19 -08:00
Alessandro Boch
cfa3682ca4 Account dcoker0 IPv6 address on daemon start
- In case --fixed-cidr-v6 is specified and docker0 bridge already
  has a global scope IPv6 address belonging to that v6 network
  (likely from a previous daemon instance), to maintain consistency
  with what done for the docker0 IPv4 address, daemon has to pass it
  down to libnetwork in the IPAMConfig as network gateway to make
  sure that the address is not given to some container.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-01-11 23:47:44 -08:00
Phil Estes
d5743a3a5c Properly report conflicting namespace options when using userns
This prevents strange errors and clarifies which namespace options are
incompatible with user namespaces (at this time).

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-01-11 20:50:22 -05:00
Alexander Morozov
9a23569ecf Merge pull request #16032 from cpuguy83/remove_sqlite_dep
Build names and links at runtime - no more sqlite
2016-01-11 10:59:49 -08:00
Santhosh Manohar
64a6dc3558 Docker changes for libnetwork vendoring..
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-01-08 14:13:55 -08:00
Phil Estes
557c7cb888 Move userns support out of experimental into master
Adds the `--userns-remap` flag to the master build

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-01-08 15:06:22 -05:00
Brian Goff
0f9f99500c Build names and links at runtime
Don't rely on sqlite db for name registration and linking.
Instead register names and links when the daemon starts to an in-memory
store.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-01-07 14:10:42 -05:00
David Calavera
907407d0b2 Modify import paths to point to the new engine-api package.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-01-06 19:48:59 -05:00
Anusha Ragunathan
5190794f1d Use ImageBuildOptions in builder.
dockerfile.Config is almost redundant with ImageBuildOptions.
Unify the two so that the latter can be removed. This also
helps build's API endpoint code to be less dependent on package
dockerfile.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-01-05 10:09:34 -08:00
Daniel Nephin
2b7ad47bd2 Move the runconfig.Parse() function into the runconfig/opts package.
The parse.go file is used almost exclusively in the client. The few small
functions that are used outside of the client could easily be copied out
when the client is extracted, allowing this runconfig/opts package to
move to the client.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2016-01-04 12:06:29 -05:00
Alessandro Boch
aa97eee1a3 Properly initialize IpamConf structure in initBridgeDriver
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-12-30 15:44:50 -08:00
Daniel Nephin
f5916b10ae Remove the graph driver from the daemon, move it into the layer store.
Support restoreCustomImage for windows with a new interface to extract
the graph driver from the LayerStore.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2015-12-28 12:55:48 -05:00
Sebastiaan van Stijn
1105caa7f1 Merge pull request #18860 from dnephin/remove_migrate_if_downlevel
Remove migrateIfDownlevel and aufs migration from docker pre-0.7
2015-12-23 00:08:36 +01:00
Daniel Nephin
0673361ef6 Remove migrateIfDownlevel and aufs migration from docker pre-0.7
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2015-12-22 16:45:42 -05:00
David Calavera
7ac4232e70 Move Config and HostConfig from runconfig to types/container.
- Make the API client library completely standalone.
- Move windows partition isolation detection to the client, so the
  driver doesn't use external types.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-22 13:34:30 -05:00
David Calavera
0aab83d996 Move blkiodev package to types.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-22 13:31:46 -05:00
Qiang Huang
8498ed73f7 Move OomKillDisable to resource
1. It's a cgroup api, fit the general defination that we take
cgroup options as kind of resource options.
2. It's common usage and very helpful as explained here:
https://github.com/docker/docker/pull/18270#issuecomment-160561316
3. It's already in `Resource` struct in
daemon/execdriver/driver_unix.go

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-12-22 16:08:04 +08:00
Ma Shimiao
843084b08b Add support for blkio read/write iops device
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
2015-12-21 09:14:49 +08:00
Tibor Vass
dc81c25031 Merge pull request #18586 from tonistiigi/tag-reference-squashed
Improve reference validation
2015-12-16 23:08:02 +01:00
Tonis Tiigi
2655954c2d Add own reference package wrapper
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2015-12-16 11:58:52 -08:00
Daniel Nephin
233a4fc33c Move ParseLink and validators into runconfig.parse where they are used.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2015-12-16 14:22:54 -05:00
Ma Shimiao
38797ca61b tfix: modify internal variable name to be lower-case
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
2015-12-15 09:50:16 +08:00
Sebastiaan van Stijn
51ffc088a5 Merge pull request #18270 from hqhq/hq_refactor_verify_config
Move verify container resources to a separate function
2015-12-12 12:47:19 +01:00
David Calavera
d7d512bb92 Rename Daemon.Get to Daemon.GetContainer.
This is more aligned with `Daemon.GetImage` and less confusing.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-11 12:39:28 -05:00
Qiang Huang
c6bfb54ac1 Move verify container resources to a separate function
Make the code easy to view.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-12-11 10:59:29 +08:00
Qiang Huang
2347f98003 Check minimum kernel memory limit to be 4M
Fixes: #18405

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-12-09 14:26:41 +08:00
Patrick Hemmer
fd9d7c02fc don't try to use default route MTU as bridge MTU
Signed-off-by: Patrick Hemmer <patrick.hemmer@gmail.com>
2015-12-07 17:32:51 -05:00
Jess Frazelle
87a614ed55 Merge pull request #17989 from jfrazelle/initial-seccomp-support
Phase 1: Initial seccomp support
2015-12-05 08:33:58 -08:00
Phil Estes
23b771782a Fix init layer chown of existing dir ownership
This solves a bug where /etc may have pre-existing permissions from
build time, but init layer setup (reworked for user namespaces) was
assuming root ownership.  Adds a test as well to catch this situation in
the future.

Minor fix to wrong ordering of chown/close on files created during the
same initlayer setup.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2015-12-04 12:18:05 -05:00
Ma Shimiao
3f15a055e5 Add support for blkio read/write bps device
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
2015-12-04 09:26:03 +08:00
Jessica Frazelle
6707f4b9b6
inital seccomp support
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2015-12-03 16:30:44 -08:00
David Calavera
6bb0d1816a Move Container to its own package.
So other packages don't need to import the daemon package when they
want to use this struct.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
2015-12-03 17:39:49 +01:00
Arnaud Porterie
8f1f53f735 Merge pull request #16277 from runcom/add-oom-score-adj
Add OomScoreAdj
2015-12-02 11:49:51 -08:00
Brian Goff
f411b101ac Merge pull request #18285 from hqhq/hq_fix_swappiness
Set default MemorySwappiness when adapt
2015-12-02 14:25:08 -05:00