Commit graph

305 commits

Author SHA1 Message Date
Sebastiaan van Stijn
57fd478169 Merge pull request #31083 from xulike666/fight-for-readability
fix some typos from module contrib to man
2017-03-03 15:13:01 +01:00
Akihiro Suda
91f11437b6 Merge pull request #30888 from estesp/moar-manifestlist-debug-output
Add debug output to manifest list parsing
2017-03-03 13:09:38 +09:00
Doug Davis
c127d9614f Add the mediaType to the error
Without this fix the error the client might see is:
	target is unknown
which wasn't helpful to me when I saw this today. With this fix I
now see:
	MediaType is unknown: 'text/html'
which helped me track down the issue to the registry I was talking to.

Signed-off-by: Doug Davis <dug@us.ibm.com>
2017-02-28 11:36:32 -08:00
Phil Estes
9a8cb9313c
Add debug output to manifest list parsing
Per request for more debug info on how the engine deals with
multi-platform "manifest list" images, this adds information about the
manifest list entries and whether it found an os/arch match, and the
digest of the match.

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2017-02-28 14:11:13 -05:00
Sebastiaan van Stijn
8606144159
log fallback errors as "info"
Fallback errors are not an error, but an
informational message.

This changes those errors to be logged
as "Info" instead of "Error".

After this patch, debug logs look like this;

    DEBU[0050] Calling GET /_ping
    DEBU[0050] Calling POST /v1.27/images/create?fromImage=localhost%3A5000%2Ffoo&tag=latest
    DEBU[0050] Trying to pull localhost:5000/foo from https://localhost:5000 v2
    WARN[0050] Error getting v2 registry: Get https://localhost:5000/v2/: http: server gave HTTP response to HTTPS client
    INFO[0050] Attempting next endpoint for pull after error: Get https://localhost:5000/v2/: http: server gave HTTP response to HTTPS client
    DEBU[0050] Trying to pull localhost:5000/foo from http://localhost:5000 v2
    INFO[0050] Attempting next endpoint for pull after error: manifest unknown: manifest unknown
    DEBU[0050] Trying to pull localhost:5000/foo from https://localhost:5000 v1
    DEBU[0050] attempting v1 ping for registry endpoint https://localhost:5000/v1/
    DEBU[0050] Fallback from error: Get https://localhost:5000/v1/_ping: http: server gave HTTP response to HTTPS client
    INFO[0050] Attempting next endpoint for pull after error: Get https://localhost:5000/v1/_ping: http: server gave HTTP response to HTTPS client
    DEBU[0050] Trying to pull localhost:5000/foo from http://localhost:5000 v1
    DEBU[0050] [registry] Calling GET http://localhost:5000/v1/repositories/foo/images
    ERRO[0050] Not continuing with pull after error: Error: image foo:latest not found

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-02-24 14:27:35 +01:00
Aaron.L.Xu
e0577d5fe8 fix some typos from module contrib to man
Signed-off-by: Aaron.L.Xu <likexu@harmonycloud.cn>
2017-02-18 10:08:55 +08:00
Vincent Demeester
c31f73abfd Merge pull request #29001 from darrenstahlmsft/WindowsOnLinux
Block pulling Windows images on non-Windows daemons
2017-02-16 19:57:54 +01:00
Derek McGowan
3a1279393f
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)
2017-02-07 11:08:37 -08:00
Darren Stahl
d55304065b Block Windows images on Linux
Signed-off-by: Darren Stahl <darst@microsoft.com>
2017-02-02 11:07:30 -08:00
Matt Moore
d5482089bf Add tracking to elided layer pulls.
Signed-off-by: Matt Moore <mattmoor@google.com>
2017-01-31 16:36:17 -08:00
Aaron Lehmann
e9c0de0de6 Merge pull request #30043 from dmcgowan/distribution-reference-update-1
Distribution reference update
2017-01-24 20:38:20 -08:00
Sebastiaan van Stijn
f633764913 Merge pull request #30262 from aaronlehmann/text-html
distribution: Add text/html and application/json as image mediatypes
2017-01-24 01:13:35 +01:00
Derek McGowan
0421f5173d
Remove use of forked reference package for cli
Use resolving to repo info as the split point between the
legitimate reference package and forked reference package.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2017-01-19 16:04:50 -08:00
Aaron Lehmann
a215e15cb1 distribution: Add text/html and application/json as image mediatypes
As noted by #30083, the new strict checking of mediatypes misses some
cases where earlier bugs caused nonstandard mediatypes to be stored in
manifests. Two of the known cases are text/html and application/json,
which were returned by certain registries and stored by earlier versions
of Docker. Add special cases for text/html and application/json.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2017-01-19 11:16:28 -08:00
Sebastiaan van Stijn
de0328560b Merge pull request #30165 from xulike666/fix-typo-6/36
[combined] fix typo
2017-01-19 17:21:22 +01:00
Aaron.L.Xu
40af569164 fix typo
fix typo I found AMAP in integration-cli/*

fix typo mentioned by Allencloud

Signed-off-by: Aaron.L.Xu <likexu@harmonycloud.cn>
2017-01-19 15:52:28 +08:00
Daehyeok Mun
6306019d0b Refactoring ineffectual assignments
This patch fixed below 4 types of code line
1. Remove unnecessary variable assignment
2. Use variables declaration instead of explicit initial zero value
3. Change variable name to underbar when variable not used
4. Add erro check and return for ignored error

Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
2017-01-13 00:27:01 -07:00
Stefan J. Wernli
d14b7212ad storeLayer.Parent should return describableStoreLayers
When storeLayer.Parent returns the parent layer, it needs to use the same logic as Get where it wraps in a describablyStoreLayer if the layer is describable. Otherwise, on Windows, this can result in pushing the foreign layers, which is not supposed to be allowed.
This fixes https://github.com/docker/docker/issues/30080.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
2017-01-11 19:01:13 -08:00
Stephen J Day
7a85579917
*: use opencontainers/go-digest package
The `digest` data type, used throughout docker for image verification
and identity, has been broken out into `opencontainers/go-digest`. This
PR updates the dependencies and moves uses over to the new type.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-01-06 18:48:41 -08:00
Sebastiaan van Stijn
d6be0e9802 Merge pull request #28631 from likel/master
Don't do format if it's unnecessary
2016-12-30 01:13:12 +01:00
Brian Goff
631f51015e Merge pull request #29684 from vdemeester/quick-unit
Enhance pkg/{httputils,integration}, distribution/xfer unit tests
2016-12-28 10:57:56 -05:00
Vincent Demeester
522bfd926b
Enhance pkg/{httputils,integration}, distribution/xfer unit tests
- Make it possible to define a shorter waiting time of httputils
- Make a small hack to reduce the waiting time on distribution/xfer

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-12-28 11:54:05 +01:00
Brian Goff
bf6eb85539 Merge pull request #29666 from tonistiigi/client-deps
Clean up client binary dependencies
2016-12-27 15:01:24 -05:00
yuexiao-wang
08c6575caf Remove unused variable
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
2016-12-28 03:20:41 +08:00
Ke Li
514adcf458 Remove redundant format
Signed-off-by: Ke Li <kel@splunk.com>

Add missing changes

Signed-off-by: Ke Li <kel@splunk.com>

User errors.New to create error

Signed-off-by: Ke Li <kel@splunk.com>
2016-12-27 21:46:52 +08:00
Tonis Tiigi
13222160e8 Define PushResult in api types
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-12-26 18:53:22 -08:00
Tonis Tiigi
3d86b0c79b Implement content addressability for plugins
Move plugins to shared distribution stack with images.

Create immutable plugin config that matches schema2 requirements.

Ensure data being pushed is same as pulled/created.

Store distribution artifacts in a blobstore.

Run init layer setup for every plugin start.

Fix breakouts from unsafe file accesses.

Add support for `docker plugin install --alias`

Uses normalized references for default names to avoid collisions when using default hosts/tags.

Some refactoring of the plugin manager to support the change, like removing the singleton manager and adding manager config struct.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2016-12-23 13:29:58 -08:00
Brian Goff
748a9a3f9c Merge pull request #29628 from liliVicky/my-feature4
modify some errors of plurality
2016-12-22 15:40:30 -05:00
Sebastiaan van Stijn
b9ee31ae02 Merge pull request #29314 from vdemeester/no-more-utils
Remove the utils package
2016-12-22 15:21:05 +01:00
liwenqi
128d07d349 modify some files
Signed-off-by: liwenqi <vikilwq@zju.edu.cn>

update some files in the folder of distribution/xfer

Signed-off-by: liwenqi <vikilwq@zju.edu.cn>

correct again

Signed-off-by: liwenqi <vikilwq@zju.edu.cn>
2016-12-22 08:38:37 +08:00
Derek McGowan
3c7676a057
Abstract distribution interfaces from image specific types
Move configurations into a single file.
Abstract download manager in pull config.
Add supports for schema2 only and schema2 type checking.
Add interface for providing push layers.
Abstract image store to generically handle configurations.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2016-12-19 10:55:00 -08:00
Anusha Ragunathan
8de2336f07 Merge pull request #29230 from vieux/remove_old_media_type_plugin
remove old media type compat for plugins
2016-12-12 12:43:32 -08:00
Vincent Demeester
0ab9320ab2
Move utils.TestDirectory to pkg/testutil/tempfile
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-12-12 09:28:32 +01:00
Victor Vieux
c1a1b381f9 Merge pull request #28459 from dmcgowan/plugin-repository-pinning
Plugin repository pinning
2016-12-08 11:28:52 -08:00
Victor Vieux
f644e758bd remove old media type compat for plugins
Signed-off-by: Victor Vieux <vieux@docker.com>
2016-12-07 17:35:09 -08:00
Alexander Morozov
523ad6ac71 Merge pull request #28966 from aaronlehmann/push-panic
distribution: Fix panic on push
2016-11-30 07:26:58 -08:00
Vincent Demeester
b5f4d3f716 Merge pull request #28954 from darrenstahlmsft/UnknownBlobRetry
Stop retrying pull on UnkownBlob error
2016-11-30 10:05:16 +01:00
Aaron Lehmann
e0702e9f37 distribution: Fix panic on push
When building a manifest during a push operation, all layers must have
an associated descriptor. If a layer is missing a descriptor, that leads
to a panic.

A break inside a switch in layerAlreadyExists meant to break from the
loop surrounding the switch, but instead breaks from the switch. This
causes the loop to continue, and can overwrite the descriptor with an
empty one, leading to the panic.

Also, fix layerAlreadyExists not to abort the push when a speculative
stat on a candidate layer digest fails with an error. This could happen
in situations like a potential cross-repository mount where the user
does not have permission to access the source repository.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-11-29 18:13:39 -08:00
Daehyeok Mun
d117a2f614 Refactoring functions
Modified newV1DependencyImage and generateDependencyImages not to return
errors instead of always return nil.

Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
2016-11-29 16:52:37 -07:00
Darren Stahl
dee2968560 Stop retrying pull on UnkownBlob error
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-11-29 15:06:25 -08:00
Derek McGowan
a12b466183
Add class to repository scope
Expose registry error translation for plugin distribution

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2016-11-21 22:18:50 -08:00
Vivek Goyal
f7f3d34210 Move CreateRWLayer() parameters in a struct
Move some of the optional parameters of CreateRWLayer() in a struct
called CreateRWLayerOpts. This will make it easy to add more options
arguments without having to change signature of CreateRWLayer().

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2016-11-16 16:31:23 -05:00
Derek McGowan
19a93a6e3d
Update pull error handling
Translate pull errors to provide a more consistent and user friendly
error message.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2016-11-10 17:34:12 -08:00
Derek McGowan
c85eb00841
Update for distribution vendor
Handle updates to reference package.
Updates for refactoring of challenge manager.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2016-11-10 17:34:12 -08:00
Victor Vieux
970b23db2e update media_type
Signed-off-by: Victor Vieux <vieux@docker.com>
2016-11-10 15:51:32 -08:00
Aaron Lehmann
99c59d5988 distribution: Remove misleading comment
Remove the following comment in pullV2Tag:

// NOTE: not using TagService.Get, since it uses HEAD requests
// against the manifests endpoint, which are not supported by
// all registry versions.

This is actually not an issue, because TagService.Get does a fallback to
GET if HEAD fails. It has done this ever since TagService was added to
the distribution API, so this comment was probably based on an early
version of TagService before it was merged, or was always a
misunderstanding.

However, we continue to use ManifestService.Get instead because it
saves a round trip. The manifest can be retrieved directly instead of
resolving the digest first.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-11-04 17:10:47 -07:00
Brian Goff
362369b4bb Adds ability to squash image after build
Allow built images to be squash to scratch.
Squashing does not destroy any images or layers, and preserves the
build cache.

Introduce a new CLI argument --squash to docker build
Introduce a new param to the build API endpoint `squash`

Once the build is complete, docker creates a new image loading the diffs
from each layer into a single new layer and references all the parent's
layers.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-11-01 13:41:59 -04:00
Sebastiaan van Stijn
762556c705 Merge pull request #26564 from miminar/prevent-blob-uploads
Avoid unnecessary blob uploads
2016-10-01 12:53:10 +02:00
Kenfe-Mickael Laventure
148aef9199 Add Map() method to LayerStore interface
This method return a map associating a chain ID to its layer object

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-09-29 07:42:53 -07:00
Michal Minář
81f7b1f1e5
Different number of retries for layers of different sizes
Classify blobs into three categories based on size.
Use a very limited number of mount attempts and no existence check for
small blobs. Use more attempts for bigger blobs.

Also remember blob associations during layer existence check.

Blob digests are now checked in the target repository from newest to
latest. If the blob exists and the metadata entry does not, it will be
created. If the blob is not found, the metadata entry will be removed.

Signed-off-by: Michal Minář <miminar@redhat.com>
2016-09-29 14:16:01 +02:00
Michal Minář
d3bd14a4fb
Allow to mock V2MetadataService in unit tests
Signed-off-by: Michal Minář <miminar@redhat.com>
2016-09-29 14:16:00 +02:00
Michal Minář
c6dd51c32c
Try to cross-repo mount until success
Don't fallback back immediately to blob upload if the cross-repo mount
fails and layer upload is initiated by registry.

Instead cancel the upload and re-try cross-repo mount from different
source repository before doing full re-upload.

Signed-off-by: Michal Minář <miminar@redhat.com>
2016-09-29 14:16:00 +02:00
Michal Minář
0928f3f2e3
Compare V2Metadata with associated auth config
to avoid unnecessary blob re-uploads.

Cross repository mount from particular repo will most probably fail if
the user pushing to the registry is not the same as the one who pulled
or pushed to the source repo.

This PR attempts first to cross-repo mount from the source repositories
associated with the pusher's auth config. Then it falls back to other
repositories sorted from the most similar to the target repo to the
least.

It also prevents metadata deletion in cases where cross-repo mount fails
and the auth config hashes differ.

Signed-off-by: Michal Minář <miminar@redhat.com>
2016-09-29 14:16:00 +02:00
John Starks
6b7d028085 Windows: Add debug output to foreign layer pull
Write the foreign layer URLs being downloaded into the debug log.

Signed-off-by: John Starks <jostarks@microsoft.com>
2016-09-26 08:56:34 -07:00
Sebastiaan van Stijn
bc22318e12 Merge pull request #26412 from YuPengZTE/devERR
In error, the first letter is low-case letter
2016-09-23 14:32:27 +02:00
YuPengZTE
4dbc78a5af In error, the first letter is low-case letter
Signed-off-by: YuPengZTE <yu.peng36@zte.com.cn>
2016-09-23 17:30:13 +08:00
Tonis Tiigi
805223982c Generalize content addressable and reference storage
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-09-15 18:08:19 -07:00
John Howard
8437d0a329 Windows: Fix regression pulling linux images
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-09-09 11:40:34 -07:00
Michael Crosby
91e197d614 Add engine-api types to docker
This moves the types for the `engine-api` repo to the existing types
package.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-09-07 11:05:58 -07:00
Qiang Huang
cec0e2dfbd Cleanup pullSchema2
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-09-05 15:02:14 +08:00
Anusha Ragunathan
9b6dcc8b9d Make docker pull detect plugin content and error out.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-08-20 12:54:35 -07:00
Alexander Morozov
6c07fbd455 Merge pull request #25090 from swernli/rootfs-cleanup
Removing old custom RootFS behavior on Windows.
2016-08-05 10:55:44 -07:00
John Howard
0eb1323fba Merge pull request #24822 from swernli/skipV1push
Fixing v2 registry restriction for non-linux platforms.
2016-07-29 14:18:47 -07:00
Stefan J. Wernli
f342b27145 Removing old custom RootFS behavior on Windows.
Windows base layers are no longer the special "layers+base" type, so we can remove all the special handling for that.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
2016-07-29 14:15:59 -07:00
Sebastiaan van Stijn
350c0281c5 Merge pull request #24819 from Microsoft/jjh/fix24766
Windows: Block (v2) pulling Linux images
2016-07-29 19:48:38 +02:00
Stephen J Day
d99c6b837f
swarm/controller: allow cancellation to propagate
Ensure that cancellation of a pull propagates rather than continuing to
container creation. This ensures that the `Prepare` method is properly
re-entrant.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2016-07-25 18:31:24 -07:00
Stefan J. Wernli
adee28458c Fixing v2 registry restriction for non-linux platforms.
This fixes the hard coded restriction for non-linux platforms to v2 registries.  Previously, the check was above the flag parsing, which would overwrite the hard coded value and prevent correct operation.  This change also removes the related daemon flag from Windows to avoid confusion, as it has no meaning when the value is going to always be hard coded to true.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
2016-07-20 16:14:40 -07:00
John Howard
4e3d7ca4ae Windows: Block (v2) pulling Linux images
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-07-19 14:34:41 -07:00
Sebastiaan van Stijn
56fb100140 Merge pull request #24568 from dmcgowan/search-v2-auth
Allow v1 search to use v2 auth with identity token
2016-07-14 19:11:33 +02:00
Derek McGowan
19d48f0b8b Allow v1 search to use v2 auth with identity token
Updates the v1 search endpoint to also support v2 auth when an identity token is given.
Only search v1 endpoint is supported since there is not v2 search currently defined to replace it.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2016-07-13 13:30:24 -07:00
Aaron Lehmann
a12ab28e0a Don't retry push on an unknown repository
If the remote registry responds with a NAME_UNKNOWN error, treat this as
a fatal error and don't retry the push.

Tested against an ECR registry.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-07-11 18:06:23 -06:00
Derek McGowan
33984f256b Always store the image digest when pulling and pushing an image.
Always attempt to add digest even when tag already exists.
Ensure digest does not currently exist.
When image id is mismatched, output an error log.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2016-06-27 10:09:57 -07:00
Aaron Lehmann
1333ef3ca3 Fix parallel push of the same image to different registries
Layer uploads are deduplicated by a "key" made up of the layer DiffID
and the repository name. The repository name being used to form this key
was a remote version of the name that didn't include the name of the
registry. Consequently, pushes of the same layer in a repository with
the same remote name to different registries would wrongly be
deduplicated.

Correct the key by using the full name of the repository, which includes
the registry hostname as well as the image's name.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-06-17 22:27:03 -07:00
Tibor Vass
f37117045c plugins: experimental support for new plugin management
This patch introduces a new experimental engine-level plugin management
with a new API and command line. Plugins can be distributed via a Docker
registry, and their lifecycle is managed by the engine.
This makes plugins a first-class construct.

For more background, have a look at issue #20363.

Documentation is in a separate commit. If you want to understand how the
new plugin system works, you can start by reading the documentation.

Note: backwards compatibility with existing plugins is maintained,
albeit they won't benefit from the advantages of the new system.

Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-06-14 14:20:27 -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
f6ff9acc63 Merge pull request #23327 from dmcgowan/refactor-foreign-layer
Refactor foreign sources to describable interfaces
2016-06-08 00:02:23 +02:00
Brian Goff
afc3cb03f4 Merge pull request #23323 from tiborvass/debug-ci
Cleanup
2016-06-06 21:03:30 -04:00
Derek McGowan
2c60430a3d Use describable interfaces
Replace use of foreign sources with descriptors and describable

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2016-06-06 17:49:34 -07:00
Arnaud Porterie
7d08f3a5ad Merge pull request #22866 from jstarks/foreign_layers
Support layers from external URLs
2016-06-07 00:27:40 +00:00
Tibor Vass
ccaea227e0 Cleanup
Signed-off-by: Tibor Vass <tibor@docker.com>
2016-06-06 15:57:51 -07:00
allencloud
c1be45fa38 fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-06-02 17:17:22 +08:00
John Starks
05bd04350b Support layers from external URLs
This is used to support downloading Windows base images from Microsoft
servers.

Signed-off-by: John Starks <jostarks@microsoft.com>
2016-05-25 19:23:02 -07:00
Vincent Demeester
636c276f67
Add Unit test to daemon.SearchRegistryForImages…
… and refactor a little bit some daemon on the way.

- Move `SearchRegistryForImages` to a new file (`daemon/search.go`) as
  `daemon.go` is getting pretty big.
- `registry.Service` is now an interface (allowing us to decouple it a
  little bit and thus unit test easily).
- Add some unit test for `SearchRegistryForImages`.
- Use UniqueExactMatch for search filters
- And use empty restore id for now in client.ContainerStart.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-05-24 11:07:11 +02:00
Michael Crosby
8bb4d31b10 Remove mountedLayer Mount and Unmount
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-05-23 16:52:58 -07:00
Yong Tang
7368e41c07 Docker pull/push with max concurrency limits.
This fix tries to address issues raised in #20936 and #22443
where `docker pull` or `docker push` fails because of the
concurrent connection failing.
Currently, the number of maximum concurrent connections is
controlled by `maxDownloadConcurrency` and `maxUploadConcurrency`
which are hardcoded to 3 and 5 respectively. Therefore, in
situations where network connections don't support multiple
downloads/uploads, failures may encounter for `docker push`
or `docker pull`.

This fix tries changes `maxDownloadConcurrency` and
`maxUploadConcurrency` to adjustable by passing
`--max-concurrent-uploads` and `--max-concurrent-downloads` to
`docker daemon` command.

The documentation related to docker daemon has been updated.

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

This fix fixes #20936. This fix fixes #22443.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-05-11 19:44:54 -07:00
Aaron Lehmann
b16fac959b Merge pull request #22316 from brettdh/registry-socks-proxy
Respect ALL_PROXY during registry operations
2016-05-06 11:29:01 -07:00
Antonio Murdaca
66fbc0c2a3 distribution: errors: do not retry on too many requests from registry
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-05-04 18:57:55 +02:00
allencloud
1ac4c61c10 fix typos in CHANGELOG.md and pull.go
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-04-29 23:33:15 +08:00
Brett Higgins
207027087e Respect ALL_PROXY during registry operations
Use sockets.DialerFromEnvironment, as is done in other places,
to transparently support SOCKS proxy config from ALL_PROXY
environment variable.

Requires the *engine* have the ALL_PROXY env var set, which
doesn't seem ideal. Maybe it should be a CLI option somehow?

Only tested with push and a v2 registry so far. I'm happy to look
further into testing more broadly, but I wanted to get feedback on
the general idea first.

Signed-off-by: Brett Higgins <brhiggins@arbor.net>
2016-04-25 15:08:30 -04: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
Aaron Lehmann
c18d03a778 Vendor distribution to correct config blob media type in schema2 manifest
@nwt noticed that the media type specified in the config section of a
schema2 manifest is application/octet-stream, instead of the correct
value application/vnd.docker.container.image.v1+json.

This brings in https://github.com/docker/distribution/pull/1622 to fix
this.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-04-11 17:29:17 -07:00
Sebastiaan van Stijn
3f39035f18 Merge pull request #21819 from tophj-ibm/fix-ensure-emptyfs-other-architectures
Fix .ensure-emptyfs on non-x86_64 architectures
2016-04-09 13:40:45 -07:00
John Howard
f2ed337ac9 Merge pull request #21740 from mindlapse/fixErrorMsg
Improved message when pushing a non-existant image
2016-04-08 20:53:25 -07:00
Christopher Jones
1f59bc8c03 Fix .ensure-emptyfs on non-x86_64 architectures
Now that we are checking if the image and host have the same architectures
via #21272, this value should be null so that the test passes on non-x86
machines

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
2016-04-08 17:38:13 -04:00
John Starks
d45a26d7e2 Windows: Support non-base-layered images
Previously, Windows only supported running with a OS-managed base image.
With this change, Windows supports normal, Linux-like layered images, too.

Signed-off-by: John Starks <jostarks@microsoft.com>
2016-04-07 17:52:26 -07:00
Alexander Morozov
5ee8652a21 all: remove some unused funcs and variables
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-04-06 10:40:01 -07:00
John Howard
fc9912fd00 Merge pull request #21272 from Microsoft/jstarks/manifest_updates
Add os_version and os_features to Image
2016-04-05 16:16:25 -07:00
John Starks
194eaa5c0f 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>
2016-04-04 13:14:57 -07:00
Dave MacDonald
e57900a269
Improved message when pushing a non-existant image
The prior error message caused confusion.  If a user attempts to push an
image up to a registry, but they misspelled (or forgot to properly tag
their image) they would see the message 'Repository does not exist', which
is not very clear and causes some to think that there might be a problem
with the registry or connectivity to it, when the problem was simply just
that an image with that tag specified does not exist locally.

Signed-off-by: Dave MacDonald <mindlapse@gmail.com>
2016-04-03 16:25:07 -04:00
Vincent Demeester
3d4b3cb424 Merge pull request #21676 from aaronlehmann/tmpfile-close
Pull: only close temporary file once
2016-03-31 11:49:37 +02:00
Sebastiaan van Stijn
ffee5588cd Merge pull request #21372 from anusha-ragunathan/ctrd-rebase
Update mount state of live containers after a daemon crash.
2016-03-30 23:10:04 -07:00
Aaron Lehmann
930ae3dbcb Pull: only close temporary file once
Close could be called twice on a temporary download file, which could
have bad side effects.

This fixes the problem by setting to ld.tmpFile to nil when the download
completes sucessfully. Then the call to ld.Close will have no effect,
and only the download manager will close the temporary file when it's
done extracting the layer from it. ld.Close will be responsible for
closing the file if we hit the retry limit and there is still a partial
download present.

Fixes #21675

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-03-30 22:44:54 -07:00
Alexander Morozov
d02e24f27d Merge pull request #21603 from aaronlehmann/testtransfer-flakiness-2
Fix flaky test TestTransfer (take 2)
2016-03-29 21:40:38 -07:00
Sebastiaan van Stijn
eaf138af1f Merge pull request #21598 from aaronlehmann/not-found-error
Change v1 pull 404 message to include tag
2016-03-29 17:28:12 -07:00
Anusha Ragunathan
511a70583f Update mount state of live containers after a daemon crash.
Fix unmount issues in the daemon crash and restart lifecycle, w.r.t
graph drivers. This change sets a live container RWLayer's activity
count to 1, so that the RWLayer is aware of the mount. Note that
containerd has experimental support for restore live containers.

Added/updated corresponding tests.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-03-29 14:42:43 -07:00
Aaron Lehmann
745892a7b2 Change v1 pull 404 message to include tag
The current error message is "Error: image [name] not found". This makes
sense from the perspective of the v1 pull, since we found the repository
doesn't exist over the v1 protocol. However, in the vast majority of
cases, this error will be produced by fallback situations, where we
first try to pull the tag with the v2 protocol, and then fall back the
v1 protocol, which probably isn't even supported by the server.
Including the tag in the error message makes a lot more sense since the
actual repository may exist on v2, but not the tag.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-03-29 10:04:59 -07:00
Aaron Lehmann
0dea21f446 Fix flaky test TestTransfer (take 2)
TestTransfer failed in CI:
https://jenkins.dockerproject.org/job/Docker-PRs-experimental/17103/console

This is the same issue as https://github.com/docker/docker/pull/21233,
but only one of the code paths was fixed in that PR. The one which
handles the first progress update was not - it still assumed that the
progress indication should be 0/10.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-03-28 18:27:29 -07:00
Shishir Mahajan
b16decfccf CLI flag for docker create(run) to change block device size.
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
2016-03-28 10:05:18 -04:00
Aaron Lehmann
c44e7a3e63 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>
2016-03-21 14:31:47 -07:00
Arnaud Porterie
278d3962a8 Merge pull request #21306 from mgoelzer/issue20001-nodeps
Pass upstream client's user agent through to registry on image pulls
2016-03-21 14:26:59 -07:00
Alexander Morozov
a05fdd6806 Merge pull request #21283 from runcom/update-test
vendor docker/distribution d06d6d3b093302c02a93153ac7b06ebc0ffd1793
2016-03-21 09:46:28 -07:00
Mike Goelzer
d1502afb63 Pass upstream client's user agent through to registry on image pulls
Changes how the Engine interacts with Registry servers on image pull.
Previously, Engine sent a User-Agent string to the Registry server
that included only the Engine's version information.  This commit
appends to that string the fields from the User-Agent sent by the
client (e.g., Compose) of the Engine.  This allows Registry server
operators to understand what tools are actually generating pulls on
their registries.

Signed-off-by: Mike Goelzer <mgoelzer@docker.com>
2016-03-20 04:30:09 -07:00
Antonio Murdaca
264b5b6083 distribution: errors: do not retry if no token in response
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-03-19 12:20:14 +01: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
Antonio Murdaca
1b5c2e1d72 distribution: errors: do not access the errors slice if it's empty
- cherry-pick from 1.10.3 branch: 0186f4d422
- add token service test suite
- add integration test (missing in 1.10.3 branch)

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-03-16 09:00:39 +01:00
Phil Estes
2b1b235acf Merge pull request #21222 from aaronlehmann/pull-with-no-layers
Fix pulling images that contain no layers at all
2016-03-15 23:03:42 -07:00
Aaron Lehmann
2f4aa96584 Fix flaky test TestTransfer
This test was checking that it received every progress update that was
produced. But delivery of these intermediate progress updates is not
guaranteed. A new update can overwrite the previous one if the previous
one hasn't been sent to the channel yet.

The call to t.Fatalf exited the current goroutine which was consuming
the channel, which caused a deadlock and eventual test timeout rather
than a proper failure message.

Failure seen here:
https://jenkins.dockerproject.org/job/Docker-PRs-experimental/16400/console

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-03-15 16:26:16 -07:00
Aaron Lehmann
7cf894ce10 Fix pulling images that contain no layers at all
The download manager assumed there was at least one layer involved in
all images. This can be false if the image is essentially a copy of
`scratch`.

Fix a nil pointer dereference that happened in this case. Add
integration tests that involve schema1 and schema2 manifests.

Fixes #21213

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-03-15 11:10:03 -07:00
Vincent Demeester
90ce409e35 Merge pull request #20949 from imjching/master
Fix typo for download and upload retry messages
2016-03-14 21:08:49 +01:00
Jay
f8d14bd4c6 Fix typo for download and upload retry messages
Signed-off-by: Jay <jay@imjching.com>
2016-03-15 00:56:19 +08:00
Aaron Lehmann
0b962f72a9 Merge pull request #21159 from runcom/fix-retry-push-bug
distribution: errors: do not retry if no credentials provided
2016-03-14 09:47:13 -07:00
Antonio Murdaca
497d545093 distribution: errors: do not retry if no credentials provided
Fix and add test for case c) in #21054

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-03-12 20:41:47 +01:00
Derek McGowan
e896d1d7c4 Add support for identity token with token handler
Use token handler options for initialization.
Update auth endpoint to set identity token in response.
Update credential store to match distribution interface changes.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2016-03-09 13:47:57 -08:00
Sebastiaan van Stijn
17156ba98f Merge pull request #20832 from aaronlehmann/login-endpoint-refactor
Update login to use token handling code from distribution
2016-03-03 19:04:42 +01:00
Aaron Lehmann
613d364e23 Merge pull request #20868 from LK4D4/unused_ctx
Remove unused ctx from v1Pusher
2016-03-02 10:05:46 -08:00
Alexander Morozov
a4dbbe7d89 Remove unused ctx from v1Pusher
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-03-02 07:59:12 -08:00
Derek McGowan
f2d481a299 Login update and endpoint refactor
Further differentiate the APIEndpoint used with V2 with the endpoint type which is only used for v1 registry interactions
Rename Endpoint to V1Endpoint and remove version ambiguity
Use distribution token handler for login

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-03-01 11:52:32 -08:00
Aaron Lehmann
5c99eebe81 Fix concurrent uploads that share layers
Concurrent uploads which share layers worked correctly as of #18353,
but unfortunately #18785 caused a regression. This PR removed the logic
that shares digests between different push sessions. This overlooked the
case where one session was waiting for another session to upload a
layer.

This commit adds back the ability to propagate this digest information,
using the distribution.Descriptor type because this is what is received
from stats and uploads, and also what is ultimately needed for building
the manifest.

Surprisingly, there was no test covering this case. This commit adds
one. It fails without the fix.

See recent comments on #9132.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-03-01 11:14:44 -08:00
Tibor Vass
8ffec1fca5 Merge pull request #20772 from Microsoft/jjh/testunitdistribution-xfer
Windows CI Unit Test: Distribution\xfer turn off failing tests
2016-02-29 10:45:57 -05:00
Sebastiaan van Stijn
da4f2ce629 Merge pull request #20771 from Microsoft/jjh/disableunittestsdistribution
Windows CI Unit Test: Distribution turn off failing tests
2016-02-29 12:56:10 +01:00
John Howard
dd2ff281bf Windows CI Unit Test: Distribution\xfer turn off failing tests
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-02-28 20:08:34 -08:00
John Howard
621a1b9aca Windows CI Unit Test: Distribution turn off failing tests
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-02-28 20:02:51 -08:00
Brian Bland
1d3480f9ba Improve fallback behavior for cross-repository push
Attempt layer mounts from up to 3 source repositories, possibly
falling back to a standard blob upload for cross repository pushes.
Addresses compatiblity issues with token servers which do not grant
multiple repository scopes, resulting in an authentication failure for
layer mounts, which would otherwise cause the push to terminate with an
error.

Signed-off-by: Brian Bland <brian.bland@docker.com>
2016-02-24 19:13:35 -08:00
Aaron Lehmann
79db131a35 Change APIEndpoint to contain the URL in a parsed format
This allows easier URL handling in code that uses APIEndpoint.
If we continued to store the URL unparsed, it would require redundant
parsing whenver we want to extract information from it. Also, parsing
the URL earlier should give improve validation.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-02-17 17:48:15 -08:00
Aaron Lehmann
5e8af46fda Smarter push/pull TLS fallback
With the --insecure-registry daemon option (or talking to a registry on
a local IP), the daemon will first try TLS, and then try plaintext if
something goes wrong with the push or pull. It doesn't make sense to try
plaintext if a HTTP request went through while using TLS. This commit
changes the logic to keep track of host/port combinations where a TLS
attempt managed to do at least one HTTP request (whether the response
code indicated success or not). If the host/port responded to a HTTP
using TLS, we won't try to make plaintext HTTP requests to it.

This will result in better error messages, which sometimes ended up
showing the result of the plaintext attempt, like this:

    Error response from daemon: Get
    http://myregistrydomain.com:5000/v2/: malformed HTTP response
    "\x15\x03\x01\x00\x02\x02"

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-02-12 13:47:48 -08:00
Vincent Demeester
e17afedfe0 Merge pull request #20247 from aaronlehmann/distribution-errors
Push/pull errors improvement and cleanup
2016-02-12 11:57:25 +01:00
David Calavera
5ca6d3bafd Merge pull request #20250 from vieux/fix_misspell
fix common misspells
2016-02-11 17:22:06 -08:00
Aaron Lehmann
8f26fe4f59 Push/pull errors improvement and cleanup
Several improvements to error handling:

- Introduce ImageConfigPullError type, wrapping errors related to
  downloading the image configuration blob in schema2. This allows for a
  more descriptive error message to be seen by the end user.

- Change some logrus.Debugf calls that display errors to logrus.Errorf.
  Add log lines in the push/pull fallback cases to make sure the errors
  leading to the fallback are shown.

- Move error-related types and functions which are only used by the
  distribution package out of the registry package.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-02-11 16:28:56 -08:00
Victor Vieux
99a396902f fix common misspell
Signed-off-by: Victor Vieux <vieux@docker.com>
2016-02-11 15:49:36 -08:00
Aaron Lehmann
7b81bc147c Fall back to V1 when there are no basic auth credentials
This makes the behavior consistent with having incorrect credentials.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-02-11 10:48:11 -08:00
Aaron Lehmann
056bf9f25e Attempt to resume downloads after certain errors
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-02-09 14:12:28 -08:00
Aaron Lehmann
f425529e7e Move temporary download file to download descriptor scope
This will allow it to be reused between download attempts in a
subsequent commit.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-02-09 14:12:28 -08:00
Alexander Morozov
9f0095f14a Merge pull request #19887 from aaronlehmann/vendor-resumable-downloads
Vendor updated distribution for resumable downloads
2016-02-05 12:58:53 -08:00
Aaron Lehmann
4d437a29d2 Vendor updated distribution for resumable downloads
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-02-04 17:33:37 -08:00
Tibor Vass
66a4e557f9 Merge pull request #19702 from tiborvass/host-specific-passthru-token
Add test to make sure the new registry pass-thru token is only sent to the intended hosts
2016-02-03 21:57:32 -05:00
Tibor Vass
3fa0d09e74 Merge pull request #19971 from aaronlehmann/revert-19743
Revert "Set idle timeouts for HTTP reads and writes in communications with the registry"
2016-02-03 15:33:29 -05:00
Alexander Morozov
bce70cdc2c Merge pull request #18680 from aaronlehmann/duplicate-pull-complete-message
Avoid outputting last progress item twice
2016-02-03 11:01:45 -08:00
Aaron Lehmann
cbda80aaff Revert "Set idle timeouts for HTTP reads and writes in communications with the registry"
This reverts commit 84b2162c1a.

The intent of this commit was to set an idle timeout on a HTTP
connection. If a read took more than 60 seconds to complete, or a write
took more than 60 seconds to complete, the connection would be
considered dead.

This doesn't work properly, because the HTTP internals apparently read
from the connection concurrently while writing. An upload that doesn't
complete in 60 seconds leads to a timeout.

Fixes #19967

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-02-03 09:59:56 -08:00
Aaron Lehmann
e273445dd4 Fix panic on network timeout during push
`Upload` already closes the reader returned by `compress` and the
progressreader passed into it, before returning. But even so, the
io.Copy inside compress' goroutine needs to attempt a read from the
progressreader to notice that it's closed, and this read has a side
effect of outputting a progress message. If this happens after `Upload`
returns, it can result in a write to a closed channel. Change `compress`
to return a channel that allows the caller to wait for its goroutine to
finish before freeing any resources connected to the reader that was
passed to it.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2016-01-29 14:34:50 -08:00
Tibor Vass
f3df50d115 distribution: add test to ensure pass-thru registry token is host-bound
Signed-off-by: Tibor Vass <tibor@docker.com>
2016-01-28 16:23:06 -08:00