Commit Graph

121 Commits

Author SHA1 Message Date
f7a6ca3323 Merge pull request #22868 from Microsoft/jjh/dockerfilecmd
Windows: CMD not honouring arg escaping
Upstream-commit: 6167a9ab166ce1e6fd0ffa653b9476d33983f15b
Component: engine
2016-07-07 09:21:26 -07:00
e4dfc2d04c Validate hostname starting from 1.24 API.
In order to keep a little bit of "sanity" on the API side, validate
hostname only starting from v1.24 API version.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 6daf3d2a783fd042e870c8af8bbd19fc28989505
Component: engine
2016-07-06 09:13:59 +02:00
0bdbf282f3 Fix spelling in comments, strings and documentation
Signed-off-by: Otto Kekäläinen <otto@seravo.fi>
Upstream-commit: 644a7426cc31c338fedb6574d2b88d1cc2f43a08
Component: engine
2016-07-03 20:58:11 +03:00
9de77e3319 Fix Malformed history layer - missing Sprintf in append of shell in Builder run config
Signed-off-by: Dan Feldman <danf@jfrog.com>
Upstream-commit: 29b6a696604d5bc80d1722e3ba123558bce7c7c9
Component: engine
2016-06-28 11:09:39 +03:00
ec8d3f9fa9 Builder/dockerfile/dispatchers.go tests
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: 5ece81a72aea6797809303aa3b68871f6ae01f6e
Component: engine
2016-06-19 14:45:34 +02:00
610f859f67 Windows: CMD not honouring arg escaping
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: d05d0211bcf43d4519bfcbbc6029fafa122f86b7
Component: engine
2016-06-15 16:46:32 -07:00
02e6cd83ac Merge pull request #23322 from tkopczynski/20784-builder-dockerfile-symlink
Reimplement integration test for symlink Dockerfile as a unit test
Upstream-commit: e08aed59dfd1642ae04ac4eb1055a378d6a572c1
Component: engine
2016-06-15 10:52:49 +02:00
f0593ff496 Reimplement integration test for symlink Dockerfile as a unit test
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: 830584b011ebf75500f307efa5425cf63e89d713
Component: engine
2016-06-14 23:07:19 +02:00
dc116784a5 Merge pull request #23093 from tkopczynski/20784-builder-dockerfile-outside-context
Builder integration tests for Dockerfile outside context as a unit test
Upstream-commit: 7d988a7aa6ae20020f0f96c6e2a47377e3567a3d
Component: engine
2016-06-14 08:44:24 +02:00
394bb94714 Fixed spelling error in builder/dockerfile/parser/parser.go
Signed-off-by: Tiffany Jernigan <tiffany.f.j@gmail.com>
Upstream-commit: a07c57f656846ee0de67ac4f575fe5b76d482efb
Component: engine
2016-06-09 14:49:59 -07:00
1a51605407 Support unicode characters in parseWords
Signed-off-by: Jonathan Stoppani <jonathan.stoppani@divio.com>
Upstream-commit: 6284f04a6b3a9b8127dc166ff84b102c8ad411ce
Component: engine
2016-06-08 14:05:08 +02:00
86b04a6a8a Merge pull request #22489 from Microsoft/jjh/shell
Builder shell configuration
Upstream-commit: df1dd1322d5c9527be7187038ca3480404b1282b
Component: engine
2016-06-05 17:43:12 +02:00
1a8439b6fb Reimplementing builder tests for Dockerfile outside context as a unit test
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: fb175bb36793ad59f2cfe9b2d92d636027fb836b
Component: engine
2016-06-05 08:39:06 +02:00
f88056a4aa Merge pull request #23232 from thaJeztah/update-default-retries
Healthcheck: set default retries to 3
Upstream-commit: 3db23a4eaf19d347c486f0f0ae764ea1b84491c0
Component: engine
2016-06-04 07:50:04 +02:00
d5ece41dcd Builder default shell
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: b18ae8c9ccc2eb6cf8aa947f25eb6f1d20089776
Component: engine
2016-06-03 13:54:31 -07:00
2c68691b95 Skip UTF-8 BOM bytes from Dockerfile if exists
This fix tries to address issues in #23221 where Dockerfile
may consists of UTF-8 BOM. This likely happens when Notepad
tries to save a file as UTF-8 in Windows.

This fix skips the UTF-8 BOM bytes from the beginning of the
Dockerfile if exists.

Additional tests has been added to cover the changes in this
fix.

This fix fixes #23221.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 678c80f9256021ce74184fdd6b612d9dea377fba
Component: engine
2016-06-03 06:16:50 -07:00
52ca58bbaa Healthcheck: set default retries to 3
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 50e470fab4ebdffff74bafeefa2f7fb8c21da13e
Component: engine
2016-06-03 13:28:08 +02:00
4524589dc5 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>
Upstream-commit: b6c7becbfe1d76b1250f6d8e991e645e13808a9c
Component: engine
2016-06-02 23:58:34 +02:00
5bcb28804b Merge pull request #22268 from Microsoft/jjh/continuationescape
Support platform semantic file paths through ESCAPE
Upstream-commit: 8e924153e219d040e3aa672df4e0c7baff9f8d8b
Component: engine
2016-05-26 10:00:56 -07:00
dd19106ac3 Typo fix wiildcard -> wildcard
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
Upstream-commit: 86d48aa111384539b0d2bd50353c4d4c40a5750a
Component: engine
2016-05-22 18:39:35 +01:00
4197623885 Reimplementing more builder integration tests as unit tests
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: cf2611f3239d18919e437e82554cec178028612e
Component: engine
2016-05-22 01:00:57 +02:00
886f3ce26b Support platform file paths through escape
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: e8e3dd32c5bad727010ec787f484b98942977531
Component: engine
2016-05-20 20:29:59 -07:00
084ac6917b builder: fixed workdir comment
Signed-off-by: Wendel Fleming <wfleming@usc.edu>
Upstream-commit: 131161bbc7a153eac0eccf02fcfb0fc2f5d368b5
Component: engine
2016-05-19 15:40:46 -05:00
e033d6beca Merge pull request #22462 from Microsoft/jjh/22181unittests
Windows: Reduce CLI time, move some to unit tests
Upstream-commit: 9de21de4531e01169d903751ab48a29457769610
Component: engine
2016-05-13 00:27:29 +02:00
af05fef951 Reimplementing builder integration tests as unit tests
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: 18eeb399852b7efe9459a1d77b0a5032a6b88bba
Component: engine
2016-05-11 22:13:39 +02:00
d1aa34c3d1 Windows: Reduce CLI time, move some to unit tests
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: faab71701f710a8862e71d4ecd6a86cef49f67b9
Component: engine
2016-05-06 12:26:08 -07:00
b06eb99229 Windows: Support ARG in builder
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 6b5c83bf18fe406e397c001acb0a1d9d7e147fd9
Component: engine
2016-05-04 14:32:23 -07:00
7cba2b7aed Merge pull request #22181 from Microsoft/jjh/workdir
Windows: Consistent build workdir handling
Upstream-commit: 2b97201e0cd8301484fde379d2bf7f0ad3f36f10
Component: engine
2016-04-26 16:51:09 -07:00
51ef85c587 Windows: Consistent build workdir handling
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 0433801093f1988db0e210e28352f4af71a0ac81
Component: engine
2016-04-26 15:32:52 -07:00
70a36f55d4 Labels set on the command line always override labels in Dockerfile
This fix tries to address the inconsistency in #22036 where labels
set on the command line will not override labels specified in
Dockerfile, but will override labels inherited from `FROM` images.

The fix add a LABEL with command line options at the end of the
processed Dockerfile so that command line options labels always
override the LABEL in Dockerfiles (or through `FROM`).

An integration test has been added for test cases specified in #22036.

This fix fixes #22036.

NOTE: Some changes are from #22266 (@tiborvass).

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 5844736c14b29860ea03b040e9a052e59ad75bfc
Component: engine
2016-04-23 18:49:17 -07:00
59ebbd5d31 Merge pull request #21817 from tkopczynski/20784-builder-dockerfile-support
Unit tests for builder/dockerfile/support
Upstream-commit: 27dd6a10b8515ed464e11ba409dd8c03b2287d1d
Component: engine
2016-04-16 13:34:35 +02:00
870f41bf45 Unit tests for builder/dockerfile/support
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: d0ebc58b9c82d2baf0c672b514ba9733ff79a3a1
Component: engine
2016-04-16 00:19:58 +02:00
4447d74a76 Move build endpoint handler from daemon (#21972)
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: 73ac6d199cacbcdba4c062f982b31f8d57e03f3c
Component: engine
2016-04-13 10:21:00 -07:00
956e3c675e Remove reference package dependency from the api.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 47afe6bd0a0dc806c36d0978a8d3e23f75ef87fe
Component: engine
2016-04-07 15:01:23 -07:00
9f10b4351a Windows: Remove TP4 support from main code
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 331c8a86d489e573fcbf1df3c4f813bbc3168624
Component: engine
2016-04-06 12:12:20 -07:00
d2a9e8f78b Merge pull request #21669 from msabansal/expose
Enabling expose support for Windows TP5
Upstream-commit: f3da0c9055ea73dec1d793d4ff524a58ad67f635
Component: engine
2016-04-06 07:52:07 -07:00
3a408aad61 Enabling expose support for Windows TP5
Signed-off-by: msabansal <sabansal@microsoft.com>
Upstream-commit: 4982a732f34640217d05eee255905fcb12a7f939
Component: engine
2016-03-30 17:25:41 -07:00
783220b8bb Apply build labels to images with only a FROM tag.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 1a85c8ebbe1ab508bcd47b883b9732c032509503
Component: engine
2016-03-30 17:28:13 -04:00
43dd16ffb4 builder: replace cancelled channel with net/context
Also stop execution of run immediately if request was cancelled.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: f2401a0f6960734093be307a27bba85a3c2ecfcd
Component: engine
2016-03-25 08:19:29 -07:00
6cee95ae99 Merge pull request #21268 from calavera/remove_dockerfile_from_api
Remove dockerfile dependency from the API.
Upstream-commit: 5ef04b1c6d1ca94c83c7ce52faae908a278ce6ea
Component: engine
2016-03-23 19:34:21 -07:00
02220a45c4 Merge pull request #21270 from ehazlett/resource-labels
Add Label support for Images (build), Networks and Volumes on Creation
Upstream-commit: 53d2e5e9d754ce8fbef733759e9ec450514133e3
Component: engine
2016-03-22 15:12:33 -04:00
fe56b4ef22 add label support for build, networks and volumes
build: implement --label

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

network: allow adding labels on create

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

volume: allow adding labels on create

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

add tests for build, network, volume

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

vendor: libnetwork and engine-api bump

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
Upstream-commit: fc214b4408d915e3510f61c7584ca01c176d1373
Component: engine
2016-03-22 11:49:06 -04:00
87c76eb0d7 Pass upstream client's user agent through to registry on operations beyond pulls
This adds support for the passthrough on build, push, login, and search.

Revamp the integration test to cover these cases and make it more
robust.

Use backticks instead of quoted strings for backslash-heavy string
contstands.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: c44e7a3e632c3ea961cb8c12ba45371f54e6699c
Component: engine
2016-03-21 14:31:47 -07:00
ae0977f1d1 fix variables that werent being called
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
Upstream-commit: 0e025b4bb16c0d4cc6b3f0c040713d061b9b051a
Component: engine
2016-03-17 13:19:55 -07:00
8366a6bcc0 remove dead code
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
Upstream-commit: 8dd88afb5b5f8ce353c00bfc71edf8238f3a0452
Component: engine
2016-03-16 19:15:14 -07:00
e4b1dba10c Remove dockerfile dependency from the API.
Move context parsing to the backend.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 93e02efa909896548496a5bd6621221aa541dc50
Component: engine
2016-03-16 22:06:29 -04:00
6decd866d9 daemon: update: check len inside public function
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: bb05c188927cdc7a5f86dceace3a4043b0dfeb28
Component: engine
2016-03-15 17:24:25 +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
98394b0b6e Vendor engine-api to 70d266e96080e3c3d63c55a4d8659e00ac1f7e6c
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Upstream-commit: 53b0d62683ee798198c553353dc2106623a9259b
Component: engine
2016-02-29 19:28:37 +08: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