Commit graph

331 commits

Author SHA1 Message Date
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
Lei Jitang
0ae94303b8 Merge pull request #19722 from WeiZhang555/exec-restarting
Forbid exec a restarting container
2016-01-27 11:43:43 +08:00
Zhang Wei
1d2208fed9 Forbid exec a restarting container
Currently if we exec a restarting container, client will fail silently,
and daemon will print error that container can't be found which is not a
very meaningful prompt to user.

This commit will stop user from exec a restarting container and gives
more explicit error message.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-01-27 10:05:06 +08:00
Arnaud Porterie
269a6d7d36 Merge pull request #19705 from mavenugo/18222
Vendor libnetwork v0.6.0-rc4 & corresponding changes in engine for port-map sandobx handling.
2016-01-26 09:16:57 -08: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
Madhu Venugopal
e38463b277 Move port-mapping ownership closer to Sandbox (from Endpoint)
https://github.com/docker/libnetwork/pull/810 provides the more complete
solution for moving the Port-mapping ownership away from endpoint and
into Sandbox. But, this PR makes the best use of existing libnetwork
design and get a step closer to the gaol.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-01-26 03:59:03 -08:00
Alessandro Boch
733245b2e7 Save endpoint config only if endpoint creation succeeds
- Currently it is being save upfront...

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-01-25 13:43:32 -08:00
Santhosh Manohar
da9eadb066 IT for service/network name with '.', corrected libnetwork flag for DNS
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-01-21 20:49:02 -08:00
Brian Goff
9ae51b3e0f Merge pull request #19383 from calavera/container_store
Extract container store from the daemon.
2016-01-21 17:20:47 -05:00
David Calavera
3c82fad441 Extract container store from the daemon.
- Generalize in an interface.
- Stop abusing of List for everything.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-01-19 13:21:41 -05:00
Daniel Dao
84e14754e1 only close LogDriver after LogCopier is done
this prevents the copier from sending messages in the buffer to the closed
driver. If the copied took longer than the timeout to drain the buffer, this
aborts the copier read loop and return back so we can cleanup resources
properly.

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2016-01-18 17:47:57 +00:00
Tibor Vass
9365b301a8 Merge pull request #19339 from cpuguy83/19335_revert_18736
Revert "Break big lock into some tiny locks"
2016-01-14 16:53:39 -05:00
David Calavera
73a5393bf3 Merge pull request #19242 from mavenugo/nsalias
Network scoped alias support
2016-01-14 10:58:51 -08:00
Brian Goff
f093e1273d Revert "Break big lock into some tiny locks"
This reverts commit 1326f0cba5.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-01-14 13:38:09 -05:00
Madhu Venugopal
dda513ef65 Network scoped alias support
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-01-14 08:44:41 -08:00
Wen Cheng Ma
9f676ade0a Add network ID to container inspect
Fixes issue #19089

Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
2016-01-14 22:33:41 +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
Tibor Vass
47074030f6 Merge pull request #19121 from WeiZhang555/tty-resize
Check nil Terminal to avoid panic
2016-01-11 11:29:15 -05:00
Sebastiaan van Stijn
967acd56c1 Merge pull request #18512 from euank/18510-fixOomKilled
Set OOMKilled state on any OOM event
2016-01-11 00:09:26 +01:00
Arnaud Porterie
fe3d1f9dd7 Merge pull request #19198 from sanimej/vin
Vendoring libnetwork
2016-01-10 11:46:34 -08:00
Sebastiaan van Stijn
a082f80832 Merge pull request #18736 from WeiZhang555/tiny-lock
Break big lock into some tiny locks for containerStart
2016-01-09 00:35:26 +01: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
Alessandro Boch
2bb3fc1bc5 Allow user to choose the IP address for the container
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-01-08 10:09:16 -08:00
Zhang Wei
7f0d304f37 Check nil Terminal to avoid panic
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2016-01-07 10:07:12 +08: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
David Calavera
723be0a332 Merge pull request #18888 from calavera/event_types
Event all the things!
2016-01-04 13:07:33 -08:00
Sebastiaan van Stijn
db738dd77f Merge pull request #15666 from vdemeester/3519-configurable-escape
Implement configurable escape key for attach/exec
2016-01-04 00:49:07 +01:00
Vincent Demeester
15aa2a663b Implement configurable detach key
Implement configurable detach keys (for `attach`, exec`, `run` and
`start`) using the client-side configuration

- Adds a `--detach-keys` flag to `attach`, `exec`, `run` and `start`
  commands.
- Adds a new configuration field (in `~/.docker/config.json`) to
  configure the default escape keys for docker client.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-01-03 23:03:39 +01:00
David Calavera
9d12d09300 Add volume events.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-30 17:39:33 -05:00
Lei Jitang
518ed75e1a Fix docker stats show wrong memory limit when do docker update
When a container create with -m 100m and then docker update other
cgroup settings such as --cpu-quota, the memory limit show by
docker stats will become the default value but not the 100m.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
2015-12-29 20:33:16 -05:00
Qiang Huang
8799c4fc0f Implemet docker update command
It's used for updating properties of one or more containers, we only
support resource configs for now. It can be extended in the future.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-12-28 19:19:26 +08:00
Zhang Wei
1326f0cba5 Break big lock into some tiny locks
Don't involve code waiting for blocking channel in locked critical
section because it has potential risk of hanging forever.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2015-12-23 13:23:23 +08: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
056e744903 Replace usage of pkg/nat with go-connections/nat.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-22 13:31:46 -05:00
David Calavera
4fef42ba20 Replace pkg/units with docker/go-units.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-16 12:26:49 -05:00
Euan
0b5131444d Set OOMKilled state on any OOM event
This restores the behavior that existed prior to #16235 for setting
OOMKilled, while retaining the additional benefits it introduced around
emitting the oom event.

This also adds a test for the most obvious OOM cases which would have
caught this regression.

Fixes #18510

Signed-off-by: Euan <euank@amazon.com>
2015-12-15 19:27:57 +00:00
Jess Frazelle
2180dd6cf0 Merge pull request #18617 from tiborvass/cleanup-builder
Cleanup builder: remove container package dependency
2015-12-15 09:59:29 -08:00
Brian Goff
ce0b1841c8 Merge pull request #17034 from rhvgoyal/volume-propagation
Capability to specify per volume mount propagation mode
2015-12-15 12:14:41 -05:00
Tibor Vass
c70f8b3c9c builder: remove container package dependency
Signed-off-by: Tibor Vass <tibor@docker.com>
2015-12-15 17:24:07 +01:00
Vivek Goyal
a2dc4f79f2 Add capability to specify mount propagation per volume
Allow passing mount propagation option shared, slave, or private as volume
property.

For example.
docker run -ti -v /root/mnt-source:/root/mnt-dest:slave fedora bash

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2015-12-14 10:39:53 -05:00
Justas Brazauskas
927b334ebf Fix typos found across repository
Signed-off-by: Justas Brazauskas <brazauskasjustas@gmail.com>
2015-12-13 18:04:12 +02:00
Qiang Huang
464eefd795 Add lock for container update
Container needs to be locked when updating the fields, and
this PR also remove the redundant `parseSecurityOpt` since
it'll be done in `setHostConfig`.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-12-11 10:33:13 +08:00
Daniel Nephin
efda9618db Move networking api types to the api/types/networking package.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-12-09 13:55:59 -08:00
Jessica Frazelle
6707f4b9b6
inital seccomp support
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2015-12-03 16:30:44 -08:00
Tibor Vass
5bb4d0d9ea Move DisconnectFromNetwork back to daemon/
Signed-off-by: Tibor Vass <tibor@docker.com>
2015-12-03 20:10:27 +01: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