Commit Graph

74 Commits

Author SHA1 Message Date
308c81e7d4 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>
Upstream-commit: b0ac69b67ef79c6c937f84bee3df20a1924ad334
Component: engine
2016-03-21 20:38:44 -04:00
a76e16e99f 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>
Upstream-commit: 94d70d835500bec3b171425271916d3e40f29635
Component: engine
2016-03-18 13:38:41 -07:00
8ba16d91c8 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>
Upstream-commit: 9c4570a958df42d1ad19364b1a8da55b891d850a
Component: engine
2016-03-18 13:38:32 -07:00
e7b1829114 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>
Upstream-commit: 53c5de29217f9633117cb01ada180d1133d76737
Component: engine
2016-03-15 08:32:35 -07:00
45ead964ff Merge pull request #21190 from runcom/cleanup
*: remove unused stuff
Upstream-commit: 68ca76320fe1ca56d6b9dfed6ca84741f957a495
Component: engine
2016-03-15 11:13:10 +01:00
4e53d3095a *: remove unused stuff
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 59648fc1e9d99cae7f4c5f692fe25a73d0651a71
Component: engine
2016-03-14 18:41:30 +01:00
1ddccf6e06 Merge pull request #21048 from LK4D4/fix_attach_leak
daemon: fix hanging attaches on initial start failures
Upstream-commit: 8e74cf59d06ce0052193ec8216db5dca7eec4981
Component: engine
2016-03-14 10:16:45 -07:00
b4a4774b91 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>
Upstream-commit: 7bb815e2960c97c5cc0624566ac51581bdd884ab
Component: engine
2016-03-10 07:38:46 -08:00
23f9a9fa41 Windows libnetwork integration
Signed-off-by: msabansal <sabansal@microsoft.com>
Upstream-commit: e8026d8a98ef30ff0ada303404e02567caebb1b0
Component: engine
2016-03-09 20:33:21 -08:00
f60019e64d Merge pull request #21019 from aboch/se
Add port configs to Sandbox and libnetwork vendoring
Upstream-commit: d99be399c35df921970bb8bebf4b4bdf774849b3
Component: engine
2016-03-09 22:27:37 -05:00
80ec175db5 Add Exposed ports and port-mapping configs to Sandbox
Signed-off-by: Alessandro Boch <aboch@docker.com>
Upstream-commit: b8a5fb76ea3d2ba3168380757cb5a746350ea451
Component: engine
2016-03-09 14:07:23 -08:00
57871b45b1 Remove obsolete comment
There is no more race

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 8706c5124a09ba4ad49ca2eb009bdcaec98b7637
Component: engine
2016-03-09 09:38:39 -08:00
e7ce25846b Merge pull request #21033 from estesp/workdir-perms-userns
Ensure WORKDIR is created with remapped root ownership
Upstream-commit: 3d09842713b98dc59a0833c0fc110c14c5778d70
Component: engine
2016-03-09 07:22:08 +01:00
98685a6505 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)
Upstream-commit: 799a6b94ee661022d66f88a009ff58f08eb5a2c3
Component: engine
2016-03-08 11:58:55 -05:00
3e9b68d581 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>
Upstream-commit: 74bb1ce9e9dbfa9dd866e84f891e865fca906d9a
Component: engine
2016-03-07 09:47:02 -08:00
3e986fd0f5 Merge pull request #20858 from mountkin/validate-log-opts-again
validate log-opt when creating containers AGAIN (fixing drunkard's code)
Upstream-commit: b65fd8e879545e8c9b859ea9b6b825ac50c79e46
Component: engine
2016-03-02 18:27:00 +01:00
5c70b34f09 validate log-opt when creating containers AGAIN
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
Upstream-commit: 068085005ef378f6320fdce90a67b104399b796d
Component: engine
2016-03-02 20:30:26 +08:00
c01546df7d Windows: Don't create working dir for Hyper-V Containers
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 5849a5537607f991898247c75e9298492318c7b1
Component: engine
2016-03-01 14:10:40 -08:00
7e3fc728ee container: container_unix: remove unused func
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 0e9769ab62ec15d56541dfbbe72316630a98b6e2
Component: engine
2016-02-29 16:12:02 +01:00
b2ac99b3fa 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>
Upstream-commit: a793564b2591035aec5412fbcbcccf220c773a4c
Component: engine
2016-02-26 15:49:09 -05:00
f153cf13ed 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>
Upstream-commit: ff3ea4c90f2ede5cccc6b49c4d2aad7201c91a4c
Component: engine
2016-02-20 17:06:32 +08:00
6d4102dcb8 Merge pull request #20133 from mlaventure/dont-bind-mount-mqueue
Prevent mqueue from implicitely becoming a bind mount with --ipc=host
Upstream-commit: 0b4a7fb06d4b77265831cee1508aad9fbeddb7a2
Component: engine
2016-02-09 19:55:57 -05:00
7d8fc9149c Merge pull request #19985 from Microsoft/CombineSetupWorkingDir
Combine SetupWorkingDirectory for Linux and Windows
Upstream-commit: d6870238e329e43d2df291a5f82d27929f9a192d
Component: engine
2016-02-09 15:18:49 -08:00
24558a48dd 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>
Upstream-commit: f7d4abdc00d521509995da1070215c808fe0fd9c
Component: engine
2016-02-09 14:16:08 -08:00
2fc41c0b8b Combine SetupWorkingDirectory for Linux and Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
Upstream-commit: 6791230320fa9f8ae9df3e90d5c52d85621828a0
Component: engine
2016-02-05 10:27:10 -08:00
1a4e7d1b20 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>
Upstream-commit: ba38d58659cc155aebf89a2ea4cfc3cd7ba04a64
Component: engine
2016-02-05 16:50:35 +01:00
93226572ef 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>
Upstream-commit: 155714c59650a7b9b8f890f4d20c83ea9b80206b
Component: engine
2016-02-02 19:50:06 +08:00
342ab710cd Signed-off-by: John Howard <jhoward@microsoft.com>
Revert "Combine SetupWorkingDirectory for Linux and Windows"

This reverts commit ec31741ca186278ea60faf49f85087c493e78806.
Upstream-commit: 54320d8d187d8b33be4fd33cfb3f8e486c6c8d90
Component: engine
2016-01-29 20:49:39 -08:00
88afeb1908 Combine SetupWorkingDirectory for Linux and Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
Upstream-commit: ec31741ca186278ea60faf49f85087c493e78806
Component: engine
2016-01-27 16:17:35 -08:00
4c547f393d Merge pull request #19722 from WeiZhang555/exec-restarting
Forbid exec a restarting container
Upstream-commit: 0ae94303b89a9648f26b599617a9d78ee5284a4c
Component: engine
2016-01-27 11:43:43 +08:00
1083d494cd 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>
Upstream-commit: 1d2208fed90da9ab72ded3b1c65bb2a71b66ce93
Component: engine
2016-01-27 10:05:06 +08:00
eed5e0f1c7 Merge pull request #19705 from mavenugo/18222
Vendor libnetwork v0.6.0-rc4 & corresponding changes in engine for port-map sandobx handling.
Upstream-commit: 269a6d7d3656fe7edf7cb630125ee4664dd24c78
Component: engine
2016-01-26 09:16:57 -08:00
4edafc3bc1 *: 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>
Upstream-commit: 4357ed4a7363a1032edf93cf03232953c805184f
Component: engine
2016-01-26 23:47:02 +11:00
578fa2d8c0 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>
Upstream-commit: e38463b2779f455b4173171d5a1fdb115180a7e9
Component: engine
2016-01-26 03:59:03 -08:00
6f75e7937c Save endpoint config only if endpoint creation succeeds
- Currently it is being save upfront...

Signed-off-by: Alessandro Boch <aboch@docker.com>
Upstream-commit: 733245b2e7517b88cdfb188f9d8418f29bca6338
Component: engine
2016-01-25 13:43:32 -08:00
4f27e3ae36 IT for service/network name with '.', corrected libnetwork flag for DNS
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
Upstream-commit: da9eadb06669b7d2b375424a31991cf97de19900
Component: engine
2016-01-21 20:49:02 -08:00
b3d838e7cb Merge pull request #19383 from calavera/container_store
Extract container store from the daemon.
Upstream-commit: 9ae51b3e0f01111b743c61d8d0811e7061b490df
Component: engine
2016-01-21 17:20:47 -05:00
793bc88c21 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>
Upstream-commit: 3c82fad44112dc73861f325bbecd68b9922b0ad3
Component: engine
2016-01-19 13:21:41 -05:00
5ce70c9580 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>
Upstream-commit: 84e14754e1ef3b089442398a31c5c5813fa9a1b6
Component: engine
2016-01-18 17:47:57 +00:00
4a4ab3133f Merge pull request #19339 from cpuguy83/19335_revert_18736
Revert "Break big lock into some tiny locks"
Upstream-commit: 9365b301a821a95e36589c990a36ea4c619b9ba1
Component: engine
2016-01-14 16:53:39 -05:00
082c746378 Merge pull request #19242 from mavenugo/nsalias
Network scoped alias support
Upstream-commit: 73a5393bf3530815a608725fe2546121ccadbfe4
Component: engine
2016-01-14 10:58:51 -08:00
49a1d12f12 Revert "Break big lock into some tiny locks"
This reverts commit 1326f0cba5f933674e23769de1385d3b0841e758.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: f093e1273d7d030a24045d97a78fec8637f46bf8
Component: engine
2016-01-14 13:38:09 -05:00
8eb1087397 Network scoped alias support
Signed-off-by: Madhu Venugopal <madhu@docker.com>
Upstream-commit: dda513ef651b42fcb9625e651f664554161c0a6a
Component: engine
2016-01-14 08:44:41 -08:00
806650627f Add network ID to container inspect
Fixes issue #19089

Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
Upstream-commit: 9f676ade0aef66bb66a26171d6bfb27f105fa1df
Component: engine
2016-01-14 22:33:41 +08:00
6c7b14647b 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>
Upstream-commit: e221b8a3d64c13178e156fc3ece5e9894dac1603
Component: engine
2016-01-12 13:38:48 -08:00
5ffd6c31d8 Merge pull request #19121 from WeiZhang555/tty-resize
Check nil Terminal to avoid panic
Upstream-commit: 47074030f6e34fc238ed503e8c8e5ae0ef526e27
Component: engine
2016-01-11 11:29:15 -05:00
ddd50b3705 Merge pull request #18512 from euank/18510-fixOomKilled
Set OOMKilled state on any OOM event
Upstream-commit: 967acd56c175b7c0f3ad4236c664730338a94bb8
Component: engine
2016-01-11 00:09:26 +01:00
7e3ab3dcd7 Merge pull request #19198 from sanimej/vin
Vendoring libnetwork
Upstream-commit: fe3d1f9dd7f2c888ad69034464cba6a35a56018f
Component: engine
2016-01-10 11:46:34 -08:00
7eedab5098 Merge pull request #18736 from WeiZhang555/tiny-lock
Break big lock into some tiny locks for containerStart
Upstream-commit: a082f8083212a50b5a3e40e2d2507b78e0a8e6a8
Component: engine
2016-01-09 00:35:26 +01:00
d8dc8b7d33 Docker changes for libnetwork vendoring..
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
Upstream-commit: 64a6dc355815261ac438b12a262e3cda7c9181df
Component: engine
2016-01-08 14:13:55 -08:00