Commit graph

195 commits

Author SHA1 Message Date
Tonis Tiigi
606a245d85 Remove restartmanager from libcontainerd
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-10-07 12:09:54 -07:00
Brian Goff
d89fb40e1c Merge pull request #27072 from Microsoft/jjh/fix26843
Windows: Don't resolve volume dest
2016-09-30 14:46:07 -04:00
John Howard
3838c314ad Windows: Don't resolve volume dest
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-09-30 09:40:15 -07:00
Tonis Tiigi
e981459609 Fix missing hostname and links in exec env
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-09-29 13:46:10 -07:00
Anusha Ragunathan
b8265e5550 Merge pull request #26843 from anusha-ragunathan/vol-unmount-win
Call "VolumeDriver.Unmount" during container stop.
2016-09-23 10:37:28 -07:00
Anusha Ragunathan
d576509d8a Call "VolumeDriver.Unmount" during container stop.
"VolumeDriver.Mount" is being called on container start.
Make the symmetric call on container stop.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-09-22 18:20:39 -07:00
msabansal
d1e0a78614 Changes required to support windows service discovery
Signed-off-by: msabansal <sabansal@microsoft.com>
2016-09-22 12:21:21 -07:00
Sebastiaan van Stijn
a28c389da1
Removed unused state functions
This removes the SetStoppedLocking, and
SetRestartingLocking functions, which
were not used anywhere.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-09-20 13:09:18 +02:00
allencloud
9279a93f6d correct some nits in comments
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-09-15 12:17:58 +08:00
Brian Goff
fc7b904dce Add new HostConfig field, Mounts.
`Mounts` allows users to specify in a much safer way the volumes they
want to use in the container.
This replaces `Binds` and `Volumes`, which both still exist, but
`Mounts` and `Binds`/`Volumes` are exclussive.
The CLI will continue to use `Binds` and `Volumes` due to concerns with
parsing the volume specs on the client side and cross-platform support
(for now).

The new API follows exactly the services mount API.

Example usage of `Mounts`:

```
$ curl -XPOST localhost:2375/containers/create -d '{
  "Image": "alpine:latest",
  "HostConfig": {
    "Mounts": [{
      "Type": "Volume",
      "Target": "/foo"
      },{
      "Type": "bind",
      "Source": "/var/run/docker.sock",
      "Target": "/var/run/docker.sock",
      },{
      "Type": "volume",
      "Name": "important_data",
      "Target": "/var/data",
      "ReadOnly": true,
      "VolumeOptions": {
	"DriverConfig": {
	  Name: "awesomeStorage",
	  Options: {"size": "10m"},
	  Labels: {"some":"label"}
	}
      }]
    }
}'
```

There are currently 2 types of mounts:

  - **bind**: Paths on the host that get mounted into the
    container. Paths must exist prior to creating the container.
  - **volume**: Volumes that persist after the
    container is removed.

Not all fields are available in each type, and validation is done to
ensure these fields aren't mixed up between types.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-09-13 09:55:35 -04:00
boucher
d8fef66b03 Initial implementation of containerd Checkpoint API.
Signed-off-by: boucher <rboucher@gmail.com>
2016-09-08 21:31:52 -04:00
Jana Radhakrishnan
99a98ccc14 Add support for docker run in swarm mode overlay
This PR adds support for running regular containers to be connected to
swarm mode multi-host network so that:
    - containers connected to the same network across the cluster can
      discover and connect to each other.
    - Get access to services(and their associated loadbalancers)
      connected to the same network

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-09-07 21:20:41 -07: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
Kenfe-Mickael Laventure
2998945a54 Re-export container state's ExitCode and Error fields
Those are needed in order to reload their value upon docker daemon
restart.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-08-30 14:17:09 -07:00
Dan Walsh
5a277c8a4a We need to relabel newly created container volumes
This will add a label to any volume that is shared into a container.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2016-08-24 08:27:01 -04:00
Lei Jitang
f4bbfc34ce Persist pause state to disk to support container live restore
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-08-19 05:32:33 -04:00
timfeirg
37466cc8c8 expose RemovalInProgress in StateString #25652
Signed-off-by: timfeirg <kkcocogogo@gmail.com>
2016-08-18 11:25:27 +08:00
Brian Goff
37302bbb3f Merge pull request #25721 from cpuguy83/revendor_engine-api
revendor engine-api
2016-08-16 17:18:43 -04:00
Brian Goff
6d98e344c7 revendor engine-api
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-08-16 14:16:12 -04:00
Zhang Wei
4754c64ab5 Forbid update restart policy of container with AutoRemove flag
"--restart" and "--rm" are conflict options, if a container is started
with AutoRemove flag, we should forbid the update action for its Restart
Policy.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-08-16 15:36:13 +08:00
lixiaobing10051267
51f927d4e5 test container state timeout with 200 milliseconds
Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn>
2016-08-10 17:19:25 +08:00
Lei Jitang
92394785fa Fix update memory without memoryswap
The memory should always be smaller than memoryswap,
we should error out with message that user know how
to do rather than just an invalid argument error if
user update the memory limit bigger than already set
memory swap.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-08-08 18:36:03 +08:00
Brian Goff
63983f3ffe Fix missing mount ID on volume unmount
Fixes #25331

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-08-02 11:24:54 -04:00
Josh Horwitz
4016038bd3 Treat HEALTHCHECK NONE the same as not setting a healthcheck
Signed-off-by: Josh Horwitz <horwitzja@gmail.com>
2016-07-25 11:11:14 -04:00
allencloud
edc307cb92 fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-07-05 20:42:17 +08:00
Brian Goff
011774e6f0 Merge pull request #23542 from mavenugo/aliases
Use service alias and configure service VIP or dns-rr
2016-06-15 16:18:50 -04:00
Arnaud Porterie
480d7b310b Merge pull request #23301 from runcom/tmpfs-trump
daemon: allow tmpfs to trump over VOLUME(s)
2016-06-15 17:11:00 +00:00
Antonio Murdaca
756f6cef4a daemon: allow tmpfs to trump over VOLUME(s)
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-06-15 16:01:51 +02:00
Madhu Venugopal
07e39e9e72 Use service alias and configure container's --net-alias
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-06-14 19:50:34 -07:00
Arnaud Porterie
bd92dd29b9 Merge pull request #23531 from tonistiigi/rm-race
Fix race on force deleting container created by task
2016-06-15 02:33:56 +00:00
Tonis Tiigi
dcfe99278d Fix race on force deleting container created by task
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-06-14 16:49:04 -07:00
Alessandro Boch
1c4efb6aa0 Allow user to specify container's link-local addresses
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-06-14 14:28:33 -07:00
Tonis Tiigi
534a90a993 Add Swarm management backend
As described in our ROADMAP.md, introduce new Swarm management API
endpoints relying on swarmkit to deploy services. It currently vendors
docker/engine-api changes.

This PR is fully backward compatible (joining a Swarm is an optional
feature of the Engine, and existing commands are not impacted).

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Victor Vieux <vieux@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-06-13 22:16:18 -07:00
Yong Tang
a72b45dbec 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.

This fix fixes #23459.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-06-11 13:16:55 -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
Alexander Morozov
3accde6dee attach: replace interface with simple type
Also add docs to detach events

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-06-03 16:40:43 -07:00
Zhang Wei
83ad006d47 Add detach event
If we attach to a running container and stream is closed afterwards, we
can never be sure if the container is stopped or detached. Adding a new
type of `detach` event can explicitly notify client that container is
detached, so client will know that there's no need to wait for its exit
code and it can move forward to next step now.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-06-03 11:59:11 +08:00
Thomas Leonard
b6c7becbfe
Add support for user-defined healthchecks
This PR adds support for user-defined health-check probes for Docker
containers. It adds a `HEALTHCHECK` instruction to the Dockerfile syntax plus
some corresponding "docker run" options. It can be used with a restart policy
to automatically restart a container if the check fails.

The `HEALTHCHECK` instruction has two forms:

* `HEALTHCHECK [OPTIONS] CMD command` (check container health by running a command inside the container)
* `HEALTHCHECK NONE` (disable any healthcheck inherited from the base image)

The `HEALTHCHECK` instruction tells Docker how to test a container to check that
it is still working. This can detect cases such as a web server that is stuck in
an infinite loop and unable to handle new connections, even though the server
process is still running.

When a container has a healthcheck specified, it has a _health status_ in
addition to its normal status. This status is initially `starting`. Whenever a
health check passes, it becomes `healthy` (whatever state it was previously in).
After a certain number of consecutive failures, it becomes `unhealthy`.

The options that can appear before `CMD` are:

* `--interval=DURATION` (default: `30s`)
* `--timeout=DURATION` (default: `30s`)
* `--retries=N` (default: `1`)

The health check will first run **interval** seconds after the container is
started, and then again **interval** seconds after each previous check completes.

If a single run of the check takes longer than **timeout** seconds then the check
is considered to have failed.

It takes **retries** consecutive failures of the health check for the container
to be considered `unhealthy`.

There can only be one `HEALTHCHECK` instruction in a Dockerfile. If you list
more than one then only the last `HEALTHCHECK` will take effect.

The command after the `CMD` keyword can be either a shell command (e.g. `HEALTHCHECK
CMD /bin/check-running`) or an _exec_ array (as with other Dockerfile commands;
see e.g. `ENTRYPOINT` for details).

The command's exit status indicates the health status of the container.
The possible values are:

- 0: success - the container is healthy and ready for use
- 1: unhealthy - the container is not working correctly
- 2: starting - the container is not ready for use yet, but is working correctly

If the probe returns 2 ("starting") when the container has already moved out of the
"starting" state then it is treated as "unhealthy" instead.

For example, to check every five minutes or so that a web-server is able to
serve the site's main page within three seconds:

    HEALTHCHECK --interval=5m --timeout=3s \
      CMD curl -f http://localhost/ || exit 1

To help debug failing probes, any output text (UTF-8 encoded) that the command writes
on stdout or stderr will be stored in the health status and can be queried with
`docker inspect`. Such output should be kept short (only the first 4096 bytes
are stored currently).

When the health status of a container changes, a `health_status` event is
generated with the new status. The health status is also displayed in the
`docker ps` output.

Signed-off-by: Thomas Leonard <thomas.leonard@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-06-02 23:58:34 +02:00
Sebastiaan van Stijn
f3a7abee81 Merge pull request #22384 from yongtang/22358-log-tag-prefix
Remove `docker/` prefix from log messages tag.
2016-05-30 14:48:31 +02:00
Brian Goff
1d87f788b1 Merge pull request #23030 from Microsoft/jjh/xenonworkdir
Windows: Default isolation and workdir
2016-05-27 11:31:36 -04:00
Brian Goff
3f6fa8af45 Merge pull request #22993 from rhatdan/relabel
Multiple fixes for SELinux labels.
2016-05-26 22:51:17 -04:00
Phil Estes
67767dba6c Merge pull request #22918 from tonistiigi/image-delete-deadlock
Release memoryStore locks before filter/apply
2016-05-26 16:00:39 -05:00
John Howard
6952135fc8 Windows: Default isolation and workdir
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-05-26 13:24:22 -07:00
Alessandro Boch
f198dfd856 Update port info on network connect/disconnect
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-25 17:02:50 -07: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
David Calavera
60abc96acf Merge pull request #22943 from vdemeester/21769-fix-detach-keys
Fix escape-keys by preserving input if invalid
2016-05-25 09:53:53 -07:00
Vincent Demeester
0fb6190243
Fix escape-keys by preserving input if invalid
Currently, using a custom detach key with an invalid sequence, eats a
part of the sequence, making it weird and difficult to enter some key
sequence.

This fixes by keeping the input read when trying to see if it's the key
sequence or not, and "writing" then is the key sequence is not the right
one, preserving the initial input.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-05-24 17:14:48 +02:00
Amit Krishnan
86d8758e2b Get the Docker Engine to build clean on Solaris
Signed-off-by: Amit Krishnan <krish.amit@gmail.com>
2016-05-23 16:37:12 -07:00
Tonis Tiigi
bd2b3d363f Release memoryStore locks before filter/apply
Rework memoryStore so that filters and apply run
on a cloned list of containers after the lock has
been released. This avoids possible deadlocks when
these filter/apply callbacks take locks for a
container.

Fixes #22732

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-05-23 11:45:04 -07:00
Yong Tang
38c49d9987 Remove docker/ prefix from log messages tag.
This fix tries to address the issue raised in #22358 where syslog's
message tag always starts with `docker/` and can not be removed
by changing the log tag templates.

The issue is that syslog driver hardcodes `path.Base(os.Args[0])`
as the prefix, which is the binary file name of the daemon (`dockerd`).
This could be an issue for certain situations (e.g., #22358) where
user may prefer not to have a dedicated prefix in syslog messages.
There is no way to override this behavior in the current verison of
the docker.

This fix tries to address this issue without making changes in the
default behavior of the syslog driver. An additional
`{{.DaemonName}}` has been introduced in the syslog tag. This is
assigned as the `docker` when daemon starts. The default log tag
template has also been changed from
`path.Base(os.Args[0]) + "/{{.ID}}"` to `{{.DaemonName}}/{{.ID}}`.
Therefore, there is no behavior changes when log-tag is not provided.

In order to be consistent, the default log tag for fluentd has been
changed from `docker.{{.ID}}` to `{{DaemonName}}.{{.ID}}` as well.

The documentation for log-tag has been updated to reflect this change.

Additional test cases have been added to cover changes in this fix.

This fix fixes #22358.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-05-12 22:29:30 -07:00
Alexander Morozov
cf783266ff Merge pull request #22279 from WeiZhang555/wait-channel
Remove WaitRunning
2016-05-12 14:56:55 -07:00
Arnaud Porterie
b3a1ae02a9 Merge pull request #22353 from Microsoft/jjh/dockercp
Windows: docker cp platform semantically consistent paths
2016-05-11 13:08:24 -10:00
John Howard
7f66598583 Windows: docker cp consistent paths
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-05-06 16:08:53 -07:00
Sebastiaan van Stijn
926725b470 Merge pull request #22433 from rhatdan/labels
We should always return the MountLabel
2016-05-07 00:24:27 +02:00
Vincent Demeester
bb125650c9 Merge pull request #21015 from cpuguy83/add_opaque_mount_id
When calling volume driver Mount, send opaque ID
2016-05-05 18:00:15 +02:00
John Howard
6b5c83bf18 Windows: Support ARG in builder
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-05-04 14:32:23 -07:00
Dan Walsh
3894773d6e We should always return the MountLabel
We need to have labels applied even if a container is running in privileged
mode.  On an tightly locked down SELinux system, this will cause running
without labels will cause SELinux to block privileged mode containers.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2016-04-30 05:46:56 -04:00
Brian Goff
2b6bc294fc When calling volume driver Mount, send opaque ID
This generates an ID string for calls to Mount/Unmount, allowing drivers
to differentiate between two callers of `Mount` and `Unmount`.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-04-29 09:37:02 -04:00
Zhang Wei
a0191a2341 Remove WaitRunning
Remove function `WaitRunning` because it's actually not necessary, also
remove wait channel for state "running" to avoid mixed use of the state
wait channel.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-04-27 11:36:47 +08:00
Michael Crosby
2b97201e0c Merge pull request #22181 from Microsoft/jjh/workdir
Windows: Consistent build workdir handling
2016-04-26 16:51:09 -07:00
John Howard
0433801093 Windows: Consistent build workdir handling
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-04-26 15:32:52 -07:00
Vincent Demeester
17d5c97c90 Merge pull request #22125 from crosbymichael/restart-timeout
Reset restart timeout if execution longer than 10s
2016-04-25 19:15:32 +02:00
Michael Crosby
b6db56b5eb Reset restart timeout if execution longer than 10s
Restore the 1.10 logic that will reset the restart manager's timeout or
backoff delay if a container executes longer than 10s reguardless of
exit status or policy.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-04-22 10:37:34 -07:00
Tonis Tiigi
ea3cbd3274 Safer file io for configuration files
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-04-21 11:31:15 -07:00
Akihiro Suda
d231260868 Clean up unused code
Signed-off-by: Akihiro Suda <suda.kyoto@gmail.com>
2016-04-14 07:04:10 +00:00
Zhang Wei
51e42e6ee0 Fix ShouldRestart for on-failure handle
Currently if you restart docker daemon, all the containers with restart
policy `on-failure` regardless of its `RestartCount` will be started,
this will make daemon cost more extra time for restart.

This commit will stop these containers to do unnecessary start on
daemon's restart.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-04-10 15:44:47 +08:00
LingFaKe
d0344731ef fix typo
Signed-off-by: Ling FaKe <lingfake@huawei.com>
2016-04-08 22:08:58 +08:00
Tonis Tiigi
20390f65c4 Fix restart monitor stopping on manual restart
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-04-07 16:12:05 -07:00
Lei Jitang
5bd1786387 Don't throw error on clenaup ipc mounts if it does not exists
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-04-06 07:34:31 -04:00
Alexander Morozov
b9966f3a81 daemon: remove some unused code
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-03-31 11:24:12 -07:00
allencloud
6983f05b42 fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-03-26 22:06:45 +08:00
Brian Goff
b0ac69b67e Add explicit flags for volume cp/no-cp
This allows a user to specify explicitly to enable
automatic copying of data from the container path to the volume path.
This does not change the default behavior of automatically copying, but
does allow a user to disable it at runtime.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-03-21 20:38:44 -04:00
John Howard
94d70d8355 Windows libcontainerd implementation
Signed-off-by: John Howard <jhoward@microsoft.com>
Signed-off-by: John Starks <jostarks@microsoft.com>
Signed-off-by: Darren Stahl <darst@microsoft.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-03-18 13:38:41 -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
Tim Hockin
53c5de2921 Don't smoosh hostname and domainname in API
This allows users to provide a FQDN as hostname or to use distinct hostname and
domainname parts.  Depends on https://github.com/docker/libnetwork/pull/950

Signed-off-by: Tim Hockin <thockin@google.com>
2016-03-15 08:32:35 -07:00
Sebastiaan van Stijn
68ca76320f Merge pull request #21190 from runcom/cleanup
*: remove unused stuff
2016-03-15 11:13:10 +01:00
Antonio Murdaca
59648fc1e9 *: remove unused stuff
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-03-14 18:41:30 +01:00
David Calavera
8e74cf59d0 Merge pull request #21048 from LK4D4/fix_attach_leak
daemon: fix hanging attaches on initial start failures
2016-03-14 10:16:45 -07:00
Alexander Morozov
7bb815e296 daemon: fix hanging attaches on initial start failures
Attach can hang forever if there is no data to send. This PR adds notification
of Attach goroutine about container stop.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-03-10 07:38:46 -08:00
msabansal
e8026d8a98 Windows libnetwork integration
Signed-off-by: msabansal <sabansal@microsoft.com>
2016-03-09 20:33:21 -08:00
Brian Goff
d99be399c3 Merge pull request #21019 from aboch/se
Add port configs to Sandbox and libnetwork vendoring
2016-03-09 22:27:37 -05:00
Alessandro Boch
b8a5fb76ea Add Exposed ports and port-mapping configs to Sandbox
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-03-09 14:07:23 -08:00
Alexander Morozov
8706c5124a Remove obsolete comment
There is no more race

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-03-09 09:38:39 -08:00
Antonio Murdaca
3d09842713 Merge pull request #21033 from estesp/workdir-perms-userns
Ensure WORKDIR is created with remapped root ownership
2016-03-09 07:22:08 +01:00
Phil Estes
799a6b94ee Ensure WORKDIR is created with remapped root ownership
Correct creation of a non-existing WORKDIR during docker build to use
remapped root uid/gid on mkdir

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2016-03-08 11:58:55 -05: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
Vincent Demeester
b65fd8e879 Merge pull request #20858 from mountkin/validate-log-opts-again
validate log-opt when creating containers AGAIN (fixing drunkard's code)
2016-03-02 18:27:00 +01:00
Shijiang Wei
068085005e validate log-opt when creating containers AGAIN
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
2016-03-02 20:30:26 +08:00
John Howard
5849a55376 Windows: Don't create working dir for Hyper-V Containers
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-03-01 14:10:40 -08:00
Antonio Murdaca
0e9769ab62 container: container_unix: remove unused func
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-02-29 16:12:02 +01: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
Zhang Wei
ff3ea4c90f Update RestartPolicy of container
Add `--restart` flag for `update` command, so we can change restart
policy for a container no matter it's running or stopped.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-02-20 17:06:32 +08:00
Tibor Vass
0b4a7fb06d Merge pull request #20133 from mlaventure/dont-bind-mount-mqueue
Prevent mqueue from implicitely becoming a bind mount with --ipc=host
2016-02-09 19:55:57 -05:00
David Calavera
d6870238e3 Merge pull request #19985 from Microsoft/CombineSetupWorkingDir
Combine SetupWorkingDirectory for Linux and Windows
2016-02-09 15:18:49 -08:00
Kenfe-Mickael Laventure
f7d4abdc00 Prevent mqueue from implicitely becoming a bind mount with --ipc=host
Currently, when running a container with --ipc=host, if /dev/mqueue is
a standard directory on the hos the daemon will bind mount it allowing
the container to create/modify files on the host.

This commit forces /dev/mqueue to always be of type mqueue except when
the user explicitely requested something to be bind mounted to
/dev/mqueue.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-02-09 14:16:08 -08:00
Darren Stahl
6791230320 Combine SetupWorkingDirectory for Linux and Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-02-05 10:27:10 -08:00
Dan Walsh
ba38d58659 Make mqueue container specific
mqueue can not be mounted on the host os and then shared into the container.
There is only one mqueue per mount namespace, so current code ends up leaking
the /dev/mqueue from the host into ALL containers.  Since SELinux changes the
label of the mqueue, only the last container is able to use the mqueue, all
other containers will get a permission denied.  If you don't have SELinux protections
sharing of the /dev/mqueue allows one container to interact in potentially hostile
ways with other containers.

Signed-off-by: Dan Walsh <dwalsh@redhat.com>
2016-02-05 16:50:35 +01:00
Zhang Wei
155714c596 Lock container when set state to restarting
After exec driver run, container lock is lost, so we should lock
container when changing its state to `restarting`

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-02-02 19:50:06 +08:00
John Howard
54320d8d18 Signed-off-by: John Howard <jhoward@microsoft.com>
Revert "Combine SetupWorkingDirectory for Linux and Windows"

This reverts commit ec31741ca1.
2016-01-29 20:49:39 -08:00
Darren Stahl
ec31741ca1 Combine SetupWorkingDirectory for Linux and Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-01-27 16:17:35 -08:00