Fix #6509: Interactive container hangs when redirecting stdout

Cli IsTerminal() SYS_IOCTL operation should be determined from STDIN,
not from STDOUT.

Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>

Docker-DCO-1.1-Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com> (github: rhatdan)
Add DockerCli IsTerminal() check for STDOUT

`docker events > /tmp/out` should not print control
characters to non-terminal STDOUT.

This addresses commit 26b4a4920adca614f6be17a96f254f331271faf0
without creating regression described in issue #6509.

Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>

Docker-DCO-1.1-Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com> (github: rhatdan)
Set container_uuid environment

If you are running with systemd as init 1 and specify the container_uuid environment
variable, systemd will create /etc/machine-id with the correct data.

Then on the host you can setup journald to watch the container.

systemd only allows 32 chars in the UUID stored in /etc/machine-id

Then we can later apply a different patch to setup journald to watch
containers from the host and log all syslog/stdout/stderr data together
int the hosts journal.

The following link explains what systemd expects to be setup.

http://www.freedesktop.org/wiki/Software/systemd/ContainerInterface/

This should replace

https://github.com/docker/docker/issues/3506

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Add --security-opts options to allow user to customize security configuration

security-opts will allow you to customise the security subsystem.

For example the labeling system like SELinux will run on a container.

    --security-opt="label:user:USER"   : Set the label user for the container
    --security-opt="label:role:ROLE"   : Set the label role for the container
    --security-opt="label:type:TYPE"   : Set the label type for the container
    --security-opt="label:level:LEVEL" : Set the label level for the container
    --security-opt="label:disabled"    : Turn off label confinement for the container

Since we are passing a list of string options instead of a space separated
string of options, I will change function calls to use InitLabels instead of
GenLabels.  Genlabels interface is Depracated.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Allow docker to search /etc/pki/entitlement for certificate files for RHEL

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Allow setting of environment variables when importing docker images

We want to be able to set the container=docker environment
variable when we build RHEL docker images.  I believe there
will be other use cases where you might want to set
environment in base images.

Since you can do this in layered image, I see no reason not
to allow it in base images.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Automatically relabel volume mounts if user passes :Z with --volume

When you volume mount into a labeled container, we want to allow the
administrator/user the ability to tell docker to fix the labels on the mount.
Using the same basic syntax as the :ro and :rw options on the --volume command

:Z will set the labels so that only the processes within the container can
read/write content.  Since the labels change on creation, this can not be done
by the administrator prior to running the container

:z will change the labels so all containers could read/write content.

drwxr-xr-x. root root system_u:object_r:svirt_sandbox_file_t:s0 /var/run/dan

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Remove TestUsage, since Usage will no longer be shown on failure to parse

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Save "META" field in Dockerfile into image content.

This will allow a user to save META data into an image, which
can later be retrieved using:

docker inspect IMAGEID

I have copied this from the "Comment" handling in docker images.

We want to be able to add json data to an image to describe the image, and
then be able to use other tools to look at this data, to be able to do
security checks based on this data.

We are thinking about adding version names, Perhaps listing the content of the dockerfile.
Descriptions of where the code came from etc.

One option is to call this flag Meta, another would be to call it Vendor.

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

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Record the content of the dockerfile in the Meta Data

This will allow someone looking at an image to see the Dockerfile used to build
it.
Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Save "COMMENT" field in Dockerfile into image content.

This will allow a user to save COMMENT data into an image, which
can later be retrieved using:

docker inspect IMAGEID

Copied the test example and some description data from Erik Hollensbe
<github@hollensbe.org>

Add support to allow docker import to populate Comment field

This patch also adds an option to docker import -m  Which will allow
base image builder to populate docker images with more comments then
just imported from FOOBAR.  This matches the docker commit -m functionality.

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

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

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
 New implementation of /run support

    This mounts a /run tmpfs into the container, with the initial contents
    copies from the /run in the base image, unless NoRunFs is set in the
    HostConfig.

    Additionally NoRunFs is always set during a docker build, which means
    any setup of /run in a Dockerfile is saved in the image to be copied
    into the final /run tmpfs when a container is started.

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

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