Commit Graph

82 Commits

Author SHA1 Message Date
7df5ef918e Move all daemon image methods into imageService
imageService provides the backend for the image API and handles the
imageStore, and referenceStore.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: 0dab53ff3cb0aae91aae068a3f1f2fd32339e23b
Component: engine
2018-02-26 16:48:29 -05:00
112db723e1 Image commit
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: bad33bbd02b9f2754d3a8c64648d46baba509680
Component: engine
2018-02-21 18:26:16 -05:00
8382b77c1c Use TagImage in Commit
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: afb3eda697efebf18d8ac3bbcfd911a5968081e3
Component: engine
2018-02-09 20:53:39 -05:00
e09b72af21 Merge pull request #36224 from dnephin/refactor-commit
Refactor Daemon.Commit()
Upstream-commit: 9769ef333f2af24b30fed0dd7b00384b2df3b953
Component: engine
2018-02-08 21:02:30 +09:00
4ec1fd107e Refactor commit
The goal of this refactor is to make it easier to integrate buildkit
and containerd snapshotters.

Commit is used from two places (api and build), each calls it
with distinct arguments. Refactored to pull out the common commit
logic and provide different interfaces for each consumer.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: daff039049aea6e19a4bda1df2834d14b4198bc0
Component: engine
2018-02-07 15:09:06 -05:00
be83c11fb0 Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: 4f0d95fa6ee7f865597c03b9e63702cdcb0f7067
Component: engine
2018-02-05 16:51:57 -05:00
40b95b8e94 Address feedback from Tonis
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 0cba7740d41369eee33b671f26276325580bc07b
Component: engine
2018-01-18 12:30:39 -08:00
852153685d LCOW: Refactor to multiple layer-stores based on feedback
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: afd305c4b5682fbc297e1685e2b7a49628b7c7f0
Component: engine
2018-01-18 08:31:05 -08:00
33860da10b LCOW: Re-coalesce stores
Signed-off-by: John Howard <jhoward@microsoft.com>

The re-coalesces the daemon stores which were split as part of the
original LCOW implementation.

This is part of the work discussed in https://github.com/moby/moby/issues/34617,
in particular see the document linked to in that issue.
Upstream-commit: ce8e529e182bde057cdfafded62c210b7293b8ba
Component: engine
2018-01-18 08:29:19 -08:00
d4d0b5c268 Move api/errdefs to errdefs
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: d453fe35b9b8b52d0677fe0c3cc8373f2f5d30d0
Component: engine
2018-01-11 21:21:43 -05:00
952c29f8da Add helpers to create errdef errors
Instead of having to create a bunch of custom error types that are doing
nothing but wrapping another error in sub-packages, use a common helper
to create errors of the requested type.

e.g. instead of re-implementing this over and over:

```go
type notFoundError struct {
  cause error
}

func(e notFoundError) Error() string {
  return e.cause.Error()
}

func(e notFoundError) NotFound() {}

func(e notFoundError) Cause() error {
  return e.cause
}
```

Packages can instead just do:

```
  errdefs.NotFound(err)
```

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 87a12421a94faac294079bebc97c8abb4180dde5
Component: engine
2018-01-11 21:21:43 -05:00
2af5d43021 Fix environ substitutions in docker commit --change ...
The building machinery was being handed an uninitialized container
Config.  This changes it to use the target container's Config.

Resolves #30538

Signed-off-by: Anthony Sottile <asottile@umich.edu>
Upstream-commit: 0785836c4b440a8d4a5dfdb8df82e50f9f4d23a1
Component: engine
2017-12-20 11:03:38 -08:00
d78181e968 Remove solaris files
For obvious reasons that it is not really supported now.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 5a9b5f10cf967f31f0856871ad08f9a0286b4a46
Component: engine
2017-10-24 15:39:34 -04:00
35db73fa01 LCOW: API: Add platform to /images/create and /build
Signed-off-by: John Howard <jhoward@microsoft.com>

This PR has the API changes described in https://github.com/moby/moby/issues/34617.
Specifically, it adds an HTTP header "X-Requested-Platform" which is a JSON-encoded
OCI Image-spec `Platform` structure.

In addition, it renames (almost all) uses of a string variable platform (and associated)
methods/functions to os. This makes it much clearer to disambiguate with the swarm
"platform" which is really os/arch. This is a stepping stone to getting the daemon towards
fully multi-platform/arch-aware, and makes it clear when "operating system" is being
referred to rather than "platform" which is misleadingly used - sometimes in the swarm
meaning, but more often as just the operating system.
Upstream-commit: 0380fbff37922cadf294851b1546f4c212c7f364
Component: engine
2017-10-06 11:44:18 -07:00
d1d8439f3f Fixes #29654: take reference to RWLayer while committing/exporting
Take an extra reference to rwlayer while the container is being
committed or exported to avoid the removal of that layer.

Also add some checks before commit/export.

Signed-off-by: Yuanhong Peng <pengyuanhong@huawei.com>
Upstream-commit: 8c32659979150630a2c4eae4e7da944806c46297
Component: engine
2017-09-22 09:47:42 +08:00
5115d455e7 LCOW: Rework after 33454 merged which refactored daemon/builder interface
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 3a09b56a10960fb740182d2a12e907f2e80b54c8
Component: engine
2017-06-20 19:50:13 -07:00
0e82890827 LCOW: commit to use image platform, not host
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 8f5378069444fba89e43b95e95d5ac630b33d90b
Component: engine
2017-06-20 19:49:52 -07:00
3af9801344 LCOW: Move daemon stores to per platform
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 3aa4a0071536d3b106374eaa44d8a55765901aa6
Component: engine
2017-06-20 19:49:52 -07:00
8508f49b3f LCOW: Pass platform through into layer store
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 42c5c1a9ec14f00d5a5367131493cbd6de7d72b0
Component: engine
2017-06-20 09:21:37 -07:00
13d2adae3f Fix copy when used with scratch and images with empty RootFS
Commit the rwLayer to get the correct DiffID
Refacator copy in thebuilder
move more code into exportImage
cleanup some windows tests
Release the newly commited layer.
Set the imageID on the buildStage after exporting a new image.
Move archiver to BuildManager.
Have ReleaseableLayer.Commit return a layer
and store the Image from exportImage in the local imageSources cache
Remove NewChild from image interface.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: 51360965206b0db49cc0365dabb590063a17a9df
Component: engine
2017-06-08 15:07:16 -04:00
932c771fa1 Remove CopyOnBuild from the daemon.
Add CreateImage() to the daemon
Refactor daemon.Comit() and expose a Image.NewChild()
Update copy to use IDMappings.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: bd5f92d2631df7c932b93e72e45b39cba19f2f3b
Component: engine
2017-06-08 15:06:54 -04:00
dbcc3f98b6 Cleanup all the mutate + defer revert of b.runConfig in the builder
Instead of mutating and reverting, just create a copy and pass the copy
around.

Add a unit test for builder dispatcher.run

Fix two test failures

Fix image history by adding a CreatedBy to commit options. Previously the
createdBy field was being created by modifying a reference to the runConfig that
was held from when the container was created.

Fix a test that expected a trailing slash. Previously the runConfig was being
modified by container create. Now that we're creating a copy of runConfig
instead of sharing a reference the runConfig retains the trailing slash.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: 9f738cc574d50d0a2accdf6f6deb30405c24a80c
Component: engine
2017-05-01 18:36:53 -04:00
e25f6c5a1b Added start period option to health check.
Signed-off-by: Elias Faxö <elias.faxo@gmail.com>
Upstream-commit: e401f63735d8ebcff387c571d1f61ce52bdea86e
Component: engine
2017-04-06 12:35:34 +02:00
2260389fe6 Use distribution reference
Remove forked reference package. Use normalized named values
everywhere and familiar functions to convert back to familiar
strings for UX and storage compatibility.

Enforce that the source repository in the distribution metadata
is always a normalized string, ignore invalid values which are not.
Update distribution tests to use normalized values.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 3a1279393faf78632bf169619d407e584da84b66
Component: engine
2017-02-07 11:08:37 -08:00
fde61754e9 commit: do not change container labels on commit
Fix #29547

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: ca6c6f0765aeccdb2730d03c05bd965906df8cd4
Component: engine
2016-12-19 09:56:20 -08:00
f53ec9c3d1 Windows: Builder case insensitive env
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 49f392ff6b528d571eac538f5365bd51c4c83e5c
Component: engine
2016-11-28 10:30:45 -08:00
dcce853abc Fix several issues with go vet and go fmt
For some reason, `go vet` and `go fmt` validate does not capture
several issues.

The following was the output of `go vet`:
```
ubuntu@ubuntu:~/docker$ go vet ./... 2>&1 | grep -v ^vendor | grep -v '^exit status 1$'
cli/command/formatter/container_test.go:393: possible formatting directive in Log call
volume/volume_test.go:257: arg mp.RW for printf verb %s of wrong type: bool
```

The following was the output of `go fmt -s`:
```
ubuntu@ubuntu:~/docker$ gofmt -s -l . | grep -v ^vendor
cli/command/stack/list.go
daemon/commit.go
```

Fixed above issues with `go vet` and `go fmt -s`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: ace786e9d517777473bd431e65d6c464d82e4f65
Component: engine
2016-11-17 06:31:28 -08:00
ba567e9b07 Remove redundant 'if' statement
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
Upstream-commit: d63dc45f0b34be6e25592ea6322a462497a89507
Component: engine
2016-11-16 16:50:54 +08:00
b7b4e2f3f9 Merge pull request #28128 from leth/commit_image_id
Add Image ID to container commit event
Upstream-commit: 90d10203a40d9f2e4247693d2154bdf0bdb6a07c
Component: engine
2016-11-10 23:14:46 -08:00
fa6bdfd965 Add Image ID & Ref to container commit event
Signed-off-by: Marcus Cobden <mcobden@cisco.com>
Upstream-commit: e60ae5380208c9329ef8be38fe3f4bdcd8ef6e83
Component: engine
2016-11-10 10:05:25 +00:00
6fb90ed484 Add functional support for Docker sub commands on Solaris
Signed-off-by: Amit Krishnan <krish.amit@gmail.com>

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 934328d8ea650bf8a9c3c719999ce2a1f5dd5df6
Component: engine
2016-11-07 09:06:34 -08:00
2a9003b823 Add basic prometheus support
This adds a metrics packages that creates additional metrics.  Add the
metrics endpoint to the docker api server under `/metrics`.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Add metrics to daemon package

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

api: use standard way for metrics route

Also add "type" query parameter

Signed-off-by: Alexander Morozov <lk4d4@docker.com>

Convert timers to ms

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 3343d234f3b131d4be1d4ca84385e184633a79bd
Component: engine
2016-10-27 10:34:38 -07:00
fe1dce6a91 pkg/archive: remove unnecessary Archive and Reader type
The `archive` package defines aliases for `io.ReadCloser` and
`io.Reader`. These don't seem to provide an benefit other than type
decoration. Per this change, several unnecessary type cases were
removed.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Upstream-commit: aa2cc18745cbe0231c33782f0fa764f657e3fb88
Component: engine
2016-10-20 19:31:24 -07:00
45ddc4bfcb 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>
Upstream-commit: 91e197d614547f0202e6ae9b8a24d88ee131d950
Component: engine
2016-09-07 11:05:58 -07: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
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
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
4815437b5f Add os_version and os_features to Image
These fields are needed to specify the exact version of Windows that an
image can run on. They may be useful for other platforms in the future.

This also changes image.store.Create to validate that the loaded image is
supported on the current machine. This change affects Linux as well, since
it now validates the architecture and OS fields.

Signed-off-by: John Starks <jostarks@microsoft.com>
Upstream-commit: 194eaa5c0f843257e66b68bd735786308a9d93b2
Component: engine
2016-04-04 13:14:57 -07:00
d35ea7bea5 Merge pull request #21454 from anusha-ragunathan/fix_overlay
Move layer mount refcounts to mountedLayer
Upstream-commit: 55bbea375100716ebc0ef16edab567b0627cff0d
Component: engine
2016-03-23 22:39:38 -04:00
778611a207 Move layer mount refcounts to mountedLayer
Instead of implementing refcounts at each graphdriver, implement this in
the layer package which is what the engine actually interacts with now.
This means interacting directly with the graphdriver is no longer
explicitly safe with regard to Get/Put calls being refcounted.

In addition, with the containerd, layers may still be mounted after
a daemon restart since we will no longer explicitly kill containers when
we shutdown or startup engine.
Because of this ref counts would need to be repopulated.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 65d79e3e5e537039b244afd7eda29e721a93d84f
Component: engine
2016-03-23 14:42:52 -07:00
fba90c19ef Revert "Move layer mount refcounts to mountedLayer"
This reverts commit 563d0711f83952e561a0d7d5c48fef9810b4f010.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: e91de9fb9d175541acc95834de486d33feef552a
Component: engine
2016-03-23 00:33:02 -07:00
44acd43622 Move layer mount refcounts to mountedLayer
Instead of implementing refcounts at each graphdriver, implement this in
the layer package which is what the engine actually interacts with now.
This means interacting directly with the graphdriver is no longer
explicitly safe with regard to Get/Put calls being refcounted.

In addition, with the containerd, layers may still be mounted after
a daemon restart since we will no longer explicitly kill containers when
we shutdown or startup engine.
Because of this ref counts would need to be repopulated.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 563d0711f83952e561a0d7d5c48fef9810b4f010
Component: engine
2016-03-22 11:36:28 -04: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
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
663efc4f39 Inherit StopSignal from Dockerfile.
Make sure the image configuration is not overriden by the default
value in the `create` flag.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: a252516ec19c9c83055a882da894712f2e812ecc
Component: engine
2016-02-12 17:56:40 -05:00
5e92886c9e Add the possibility to log event with specific attributes
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 1d8ccc6ae7dafde55cf4458e3119f61c83ccbc4a
Component: engine
2016-01-17 12:14:01 +01:00
4ec2693c9e Modify import paths to point to the new engine-api package.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 907407d0b2e5863f0e1b40b93a356bbf03c7b9fb
Component: engine
2016-01-06 19:48:59 -05:00
510a74def2 Remove runconfig.Merge
Merge was used by builder and daemon. With this commit, the builder
call has been inlined and the function moved to the daemon package,
which is the only other caller.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: eb4ae8e28aa0baf28d6cde1079a5f9c618d475b2
Component: engine
2016-01-05 11:28:55 -08:00
64820f351d Refactor RWLayer to use referenced object instead of string
RWLayer will now have more operations and be protected through a referenced type rather than always looked up by string in the layer store.
Separates creation of RWLayer (write capture layer) from mounting of the layer.
This allows mount labels to be applied after creation and allowing RWLayer objects to have the same lifespan as a container without performance regressions from requiring mount.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: d04fa49a0dec89d2f71a813ce8eaa182184139c5
Component: engine
2015-12-23 11:19:17 -08:00
020b74d545 Add own reference package wrapper
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: 2655954c2dd9d92c2394b04e4262543174c4c038
Component: engine
2015-12-16 11:58:52 -08:00