Add vendored version of github.com/guelfey/go.dbus

We need this to do systemd API calls.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Add vendored version of github.com/coreos/go-systemd

We need this to do systemd API calls.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
pkg/systemd: Drop our copy-pasted version of go-systemd/activation

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Add systemd.SdBooted()

This is a conversion of sd_booted() from libsystemd to go and checks
if the system was booted with systemd.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
execdriver: Make Config field more generic

In order to handle special configuration for other backends we
make the Config field a map to key-value arrays. This lets
us use it for lxc, by using the "lxc" key for those, and we can
later extend it easily for other backend-specific options.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
cgroups: Splity out Apply/Cleanup to separate file/interface

This leaves only the generic cgroup helper functions in cgroups.go and
will allow easy implementations of other cgroup managers.

This also wires up the call to Cleanup the cgroup which was missing
before.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
cgroups: Join groups by writing to cgroups.procs, not tasks

cgroups.procs moves all the threads of the process, and "tasks" just
the one thread. I believe there is a risk that we move the main thread,
but then we accidentally fork off one of the other threads if the go
scheduler randomly switched to another thread. So, it seems safer (and
more correct) to use cgroups.procs.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
cgroups: Add systemd implementation of cgroups

This implements cgroup.Apply() using the systemd apis.
We create a transient unit called "docker-$id.scope" that contains
the container processes. We also have a way to set unit specific
properties, currently only defining the Slice to put the
scope in.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Make execdriver a per container property

This way we can have different (non-default) exec drivers for some
containers.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Add "foreground" mode for docker run

This is a mode of "docker run" that uses direct forking from the
docker client, meaning that the container is a direct child of the
docker run command (rather than the daemon), and that it directly
inherits stdout/err (and stdin if requested) from the parent of the
"docker run" command.

This is very useful in cases where you e.g. want to run a docker
container from systemd (or other process manager), as we can use the
process manager to e.g. set up cgroups and limits, monitor and
restart, pass in fds for socket activation, etc.

The way this works is that there is a new execdriver, which is used
for forground containers. This container just does rpc calls back to
the "docker run" command, which in turn uses a "real" execdriver and
feeds it whatever data the "fake" execdriver got, but in the context
of the docker run command.

We feed information about the process (exit status, pid, etc) to the
daemon, so it is visible just like any other docker container via the
docker apis.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Merge branch 'forking-run' into forking-run-systemd
cgroup: Add ReuseCurrent option to --unit-conf

This causes docker to not create a new transient unit for cgroup
containment and resource limits. Instead it will reuse the current
cgroup and apply resource limitations to it using SetUnitProperties.

This is interesting mostly in combination with --foreground, because
it allows you to have a systemd unit file like:

[Service]
ExecStart=docker run --foreground --unit-conf ReuseCurrent=true run image
MemoryLimit=100M

With the following properties:

* Any limits and other properties set up in the service file applies
  to both the docker client and the container "as one unit".
* There is only one unit representing the service
* You can kill the service via systemd which will kill both client and
  container.
* If the client dies systemd will (first nicely then violently) kill the
  other processes in the cgroup (i.e. the container).

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)

Conflicts:
	pkg/cgroups/apply_systemd.go
Ignore *.patch and *~ in git

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Setup LISTEN_PID correctly for socket activations
Inform processes in the container that they are running in a docker container

Init systems like systemd use this to determine they are running in a non
privleged environment.
Remount /var/lib/docker as --private to fix scaling issue

If an admin mounts all file systems as -rshared (Default on RHEL and Fedora)
we see a scaling problem as the number of container increase.

Basically every new container needs to have it new mounts in /var/lib/docker
shared to all other containers, this ends up with us only able to scale to
around 100 containers, before the system slows down.

By simply bind mounting /var/lib/docker on its and then setting it private,
the scaling issue goes away.
Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)

Conflicts:
	docker/docker.go
This patch adds SELinux labeling support.

docker will run the process(es) within the container with an SELinux label and will label
all of  the content within the container with mount label.  Any temporary file systems
created within the container need to be mounted with the same mount label.

The user can override the process label by specifying

-Z With a string of space separated options.

-Z "user=unconfined_u role=unconfined_r type=unconfined_t level=s0"

Would cause the process label to run with unconfined_u:unconfined_r:unconfined_t:s0"

By default the processes will run execute within the container as svirt_lxc_net_t.
All of the content in the container as svirt_sandbox_file_t.

The process mcs level is based of the PID of the docker process that is creating the container.

If you run the container in --priv mode, the labeling will be disabled.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)

Conflicts:
	hack/PACKAGERS.md
	pkg/libcontainer/nsinit/init.go
	runconfig/parse.go
	runtime/execdriver/driver.go
	runtime/execdriver/lxc/lxc_template.go
unrelated conflicts in hack/PACKAGERS.md