Commit Graph

1118 Commits

Author SHA1 Message Date
Felix Fontein 3178c8d48b
deps: compatiblity with requests ≥ 2.29.0 and urllib3 2.x (#3116)
Requirements are the same, so it's still possible to use `urllib3 < 2`
or `requests == 2.28.2` for example.

Signed-off-by: Felix Fontein <felix@fontein.de>
2023-05-05 11:39:31 -04:00
Lorin Bucher 7cd7458f2f
api: add `status` parameter to services list (#3093)
Signed-off-by: Lorin Bucher <lorin@lbtec.dev>
2023-02-16 10:38:52 -05:00
Andy Roxby e9d4ddfaec
api: add `one-shot` option to container `stats` (#3089)
Signed-off-by: Andy Roxby <107427605+aroxby-wayscript@users.noreply.github.com>
2023-02-16 10:27:45 -05:00
Milas Bowman aca129dd69 Merge branch 'master'
(Old PR unintentionally went to the `master` branch.)
2023-01-27 09:27:42 -05:00
Mariano Scazzariello ee9151f336
client: add `network_driver_opt` to container run and create (#3083)
Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
2023-01-27 09:26:21 -05:00
Yanlong Wang 22718ba59a
fix(store): warn on init instead of throw (#3080)
Signed-off-by: yanlong.wang <yanlong.wang@naiver.org>
2023-01-10 17:45:25 -05:00
loicleyendecker 82cf559b5a
volume: do not strip trailing characters from names (#3073)
Only remove `:ro` or `:rw` suffixes in their entirety; do not
strip arbitrary `r` / `o` / `w` / `:` characters individually.

Signed-off-by: Loïc Leyendecker <loic.leyendecker@gmail.com>
2022-12-02 14:48:04 -05:00
Brian Goff bc0a5fbacd
test: use anonymous volume for prune (#3051)
This is related to https://github.com/moby/moby/pull/44216

Prunes will, by default, no longer prune named volumes, only anonymous ones.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-10-05 13:54:45 -04:00
Rhiza 923e067ddd
api: add support for floats to docker logs params since / until (#3031)
Add support for floats to docker logs params `since` / `until` since the
Docker Engine APIs support it.

This allows using fractional seconds for greater precision.

Signed-off-by: Archi Moebius <poerhiz@gmail.com>
2022-08-19 15:10:53 -04:00
Sebastiaan van Stijn 1c27ec1f0c
ci: use latest stable syntax for Dockerfiles (#3035)
I noticed one Dockerfile was pinned to 1.4; given that there's a
backward compatibility guarantee on the stable syntax, the general
recommendation is to use `dockerfile:1`, which makes sure that the
latest stable release of the Dockerfile syntax is pulled before
building.

While changing, I also made some minor changes to some Dockerfiles
to reduce some unneeded layers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-08-19 15:09:12 -04:00
Milas Bowman e901eac7a8
test: add additional tests for cgroupns option (#3024)
See #2930.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-12 14:27:53 -04:00
Chris Hand fc86ab0d85
swarm: add support for DataPathPort on init (#2987)
Adds support for setting the UDP port used for VXLAN traffic between
swarm nodes

Signed-off-by: Chris Hand <dexteradeus@users.noreply.github.com>
2022-08-12 09:58:57 -04:00
Milas Bowman c03aeb659e Merge remote-tracking branch 'upstream/main' into connect-with-mac 2022-08-12 09:21:51 -04:00
Quentin Mathorel 58aa62bb15
swarm: add sysctl support for services (#3029)
Signed-off-by: Quentin Mathorel <quentin.mathorel@outlook.fr>
2022-08-12 08:55:19 -04:00
Milas Bowman ff0b4ac60b
docs: add changelog for 6.0.0 (#3019)
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-08-11 17:20:13 -04:00
Leonard Kinday 66402435d1
Support `global-job` and `replicated-job` modes in Docker Swarm (#3016)
Add `global-job` and `replicated-job` modes

Fixes #2829.

Signed-off-by: Leonard Kinday <leonard@kinday.ru>
2022-08-11 16:20:31 -04:00
Ningú 42789818be
credentials: eliminate distutils deprecation warnings (#3028)
While removing any usage of the deprecated `distutils` package,
("The distutils package is deprecated and slated for removal in Python 3.12.")
this internal utility can be removed straightaway because the
`shutil.which` replacement for `distutils.spawn.find_executable`
already honors the `PATHEXT` environment variable in windows systems.

See https://docs.python.org/3/library/shutil.html#shutil.which

Signed-off-by: Daniel Möller <n1ngu@riseup.net>
2022-08-02 10:19:50 -04:00
Milas Bowman cd2c35a9b6
ci: add workflow for releases (#3018)
GitHub Actions workflow to create a release: will upload to PyPI
and create a GitHub release with the `sdist` and `bdist_wheel`
as well.

The version code is switched to `setuptools_scm` to work well
with this flow (e.g. avoid needing to write a script that does
a `sed` on the version file and commits as part of release).

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-30 12:14:27 -04:00
Clément Loiselet 3ee3a2486f
build: trim trailing whitespace from dockerignore entries (#2733)
fix(dockerignore): trim trailing whitespace

Signed-off-by: Clément Loiselet <clement.loiselet@capgemini.com>
2022-07-29 15:33:23 -04:00
Milas Bowman 868e996269
model: add remove() to Image (#3026)
Allow an Image to be deleted by calling the remove() method on it,
just like a Volume.

Signed-off-by: Ahmon Dancy <dancy@dancysoft.com>
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
Co-authored-by: Ahmon Dancy <dancy@dancysoft.com>
2022-07-29 15:28:16 -04:00
ercildoune 26753c81de
api: add rollback_config to service create (#2917)
`rollback_config` was not in the list of `CREATE_SERVICE_KWARGS`
which prevented it from being an argument when creating services.
It has now been added and the problem fixed, allowing services to
have a rollback_config during creation and updating.

Fixes #2832.

Signed-off-by: Fraser Patten <pattenf00@gmail.com>
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
Co-authored-by: Milas Bowman <milas.bowman@docker.com>
2022-07-29 14:54:55 -04:00
Till! 0031ac2186
api: add force to plugin disable (#2843)
Signed-off-by: till <till@php.net>
2022-07-29 14:51:43 -04:00
David d69de54d7c
api: add cgroupns option to container create (#2930)
Signed-off-by: David Otto <ottodavid@gmx.net>
2022-07-29 14:04:47 -04:00
Felix Fontein 1a4cacdfb6
api: add platform to container create (#2927)
Add platform parameter for container creation/run

Signed-off-by: Felix Fontein <felix@fontein.de>
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
Co-authored-by: Milas Bowman <milas.bowman@docker.com>
2022-07-29 13:57:30 -04:00
Milas Bowman 26064dd6b5
deps: upgrade websocket-client to latest (#3022)
* Upgrade websocket-client to latest
* Add basic integration test for streaming logs via websocket

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-29 11:09:47 -04:00
Ben Fasoli 23cf16f03a
client: use 12 character short IDs (#2862)
Use 12 characters for Docker resource IDs for
consistency with the Docker CLI.

Signed-off-by: Ben Fasoli <benfasoli@gmail.com>
2022-07-29 09:06:22 -04:00
Milas Bowman acdafbc116
ci: run SSH integration tests (#3012)
Fix & enable SSH integration test suite.

This also adds a new test for connecting to unknown hosts when
using the Python SSH implementation (Paramiko). See #2932 for
more info.

Because of the above, some of the config/static key files have been
moved around and adjusted.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-27 16:25:27 -04:00
Karthikeyan Singaravelan adf5a97b12
lint: fix deprecation warnings from threading package (#2823)
Set `daemon` attribute instead of using `setDaemon` method that
was deprecated in Python 3.10.

Signed-off-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
2022-07-27 15:25:11 -04:00
Milas Bowman 52e29bd446
deps: remove backports.ssl_match_hostname (#3011)
This is no longer needed as it exists in every supported (non-EOL)
version of Python that we target.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-27 14:44:50 -04:00
Milas Bowman da62a28837
deps: test on Python 3.10 by default (#3010)
* Upgrade to latest Sphinx / recommonmark
* Small CSS fix for issue in new version of Alabaster theme
* Fix `Makefile` target for macOS

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-27 14:44:36 -04:00
Milas Bowman b9ca58a56d
Merge pull request #3009 from milas/lint-flake8
ci: add flake8 job
2022-07-26 15:48:55 -04:00
Milas Bowman 3ffdd8a1c5 lint: fix outstanding flake8 violations
Since flake8 wasn't actually being run in CI, we'd accumulated some
violations.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-26 13:48:47 -04:00
Milas Bowman 4765f62441 test: mark invalid test as xfail
This test looks for some behavior on non-chunked HTTP requests.

It now fails because it looks like recent versions of Docker Engine
ALWAYS return chunked responses (or perhaps this specific response
changed somehow to now trigger chunking whereas it did not previously).

The actual logic it's trying to test is also unusual because it's
trying to hackily propagate errors under the assumption that it'd get
a non-chunked response on failure, which is...not reliable. Arguably,
the chunked reader should be refactored somehow but that's a refactor
we can't really commit to (and it's evidently been ok enough as is
up until now).

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-26 13:00:49 -04:00
Milas Bowman 74e0c5eb8c test: fix flaky container log test
Ensure the container has exited before attempting to grab the logs.

Since we are not streaming them, it's possible to attach + grab logs
before the output is processed, resulting in a test failure. If the
container has exited, it's guaranteed to have logged :)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-26 13:00:49 -04:00
Sebastiaan van Stijn 7168e09b16
test: fix for cgroupv2 (#2940)
This test was verifying that the container has the right options set (through
`docker inspect`), but also checks if the cgroup-rules are set within the
container by reading `/sys/fs/cgroup/devices/devices.list`

Unlike cgroups v1, on cgroups v2, there is no file interface, and rules are
handled through ebpf, which means that the test will fail because this file
is not present.

From the Linux documentation for cgroups v2:
https://github.com/torvalds/linux/blob/v5.16/Documentation/admin-guide/cgroup-v2.rst#device-controller

> (...)
> Device controller manages access to device files. It includes both creation of
> new device files (using mknod), and access to the existing device files.
>
> Cgroup v2 device controller has no interface files and is implemented on top
> of cgroup BPF. To control access to device files, a user may create bpf programs
> of type BPF_PROG_TYPE_CGROUP_DEVICE and attach them to cgroups with
> BPF_CGROUP_DEVICE flag. (...)

Given that setting the right cgroups is not really a responsibility of this SDK,
it should be sufficient to verify that the right options were set in the container
configuration, so this patch is removing the part that checks the cgroup, to
allow this test to be run on a host with cgroups v2 enabled.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-26 12:06:51 -04:00
Milas Bowman f16c4e1147
utils: fix IPv6 address w/ port parsing (#3006)
This was using a deprecated function (`urllib.splitnport`),
ostensibly to work around issues with brackets on IPv6 addresses.

Ironically, its usage was broken, and would result in mangled IPv6
addresses if they had a port specified in some instances.

Usage of the deprecated function has been eliminated and extra test
cases added where missing. All existing cases pass as-is. (The only
other change to the test was to improve assertion messages.)

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-07-26 11:35:44 -04:00
Hugo van Kemenade 4bb99311e2 Don't install mock backport
Signed-off-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2021-10-11 23:06:12 +03:00
Anca Iordache 7779b84e87
Merge pull request #2809 from feliperuhland/add-service-capability
Add service capability
2021-10-08 00:01:28 +02:00
Anca Iordache aae6be0c58
Merge branch 'master' into feat/add_templating_parameter_docker_config 2021-10-07 23:29:03 +02:00
Anthony Sottile 5fcc293ba2 use python3.6+ constructs
Signed-off-by: Anthony Sottile <asottile@umich.edu>
2021-07-05 18:30:07 -04:00
Sebastiano Mariani f42a81dca2 Add the possibility to set a templating driver when creating a new Docker config
Signed-off-by: Sebastiano Mariani <smariani@vmware.com>
2021-06-03 15:51:52 -07:00
Felipe Ruhland 7ac8b56730 Add `CapabilityAdd` and `CapabilityDrop` to
ContainerSpec

Docker Engine v1.41 added `CapAdd` and `CapDrop` as part of the
ContainerSpec, and `docker-py` should do the same.

```
GET /services now returns CapAdd and CapDrop as part of the ContainerSpec.
GET /services/{id} now returns CapAdd and CapDrop as part of the ContainerSpec.
POST /services/create now accepts CapAdd and CapDrop as part of the ContainerSpec.
POST /services/{id}/update now accepts CapAdd and CapDrop as part of the ContainerSpec.
GET /tasks now returns CapAdd and CapDrop as part of the ContainerSpec.
GET /tasks/{id} now returns CapAdd and CapDrop as part of the ContainerSpec.
```

I added capabilities on docstrings, `service.create` init method and
create tests for that.

That change was mention in issue #2802.

Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
2021-04-07 22:11:52 +02:00
Anca Iordache 18fdc23b7c
Merge pull request #2476 from feliperuhland/add-search-images-limit
Add limit parameter to image search endpoint
2021-04-06 14:43:07 +01:00
Anca Iordache 30d482d359
Merge pull request #2788 from docker/set-minimal-python-to-3_6
Make python 3.6 the minimum version
2021-03-25 09:59:41 +01:00
Felipe Ruhland d4310b2db0 Fix `KeyError` when creating a new secret
How to reproduce the issue:

```py
>>> import docker
>>> cli = docker.from_env()
>>> cli.secrets.create(name="any_name", data="1")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/docker-py/docker/models/secrets.py", line 10, in __repr__
    return "<%s: '%s'>" % (self.__class__.__name__, self.name)
  File "/home/docker-py/docker/models/secrets.py", line 14, in name
    return self.attrs['Spec']['Name']
KeyError: 'Spec'
```

The exception raises because create secrets API `/secrets/create` only
return the `id` attribute:
https://docs.docker.com/engine/api/v1.41/#operation/SecretCreate
The secret model is created using just the `id` attribute and fails
when looking for Spec.Name attribute.

```py
def __repr__(self):
    return "<%s: '%s'>" % (self.__class__.__name__, self.name)
```

```py
@property
def name(self):
    return self.attrs['Spec']['Name']
```

I came up with a ugly solution but will prevent the problem to happen
again:

```py
def create(self, **kwargs):
    obj = self.client.api.create_secret(**kwargs)
+   obj.setdefault("Spec", {})["Name"] = kwargs.get("name")
    return self.prepare_model(obj)
```

After the API call, I added the name attribute to the right place to be
used on the property name.

```py
>>> import docker
>>> cli = docker.from_env()
>>> cli.secrets.create(name="any_name", data="1")
<Secret: 'any_name'>
```

It isn't the most elegant solution, but it will do the trick.
I had a previous PR #2517 when I propose using the `id` attribute
instead of `name` on the `__repr__` method, but I think this one will be better.

That fixes #2025

Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
2021-03-24 18:03:54 +01:00
Ulysses Souza c8fba210a2 Remove support to pre python 3.6
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-03-22 10:18:23 -03:00
Nicolas De Loof 563124163a relax PORT_SPEC regex so it accept and ignore square brackets
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-03-10 11:25:18 +01:00
Felipe Ruhland 7d316641a3 Add limit parameter to image search endpoint
Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
2021-02-24 23:42:20 +01:00
aiordache 2807fde6c9 Fix SSH port parsing and add regression tests
Signed-off-by: aiordache <anca.iordache@docker.com>
2021-02-18 10:56:29 -03:00
WojciechowskiPiotr 6d1dffe3e5 Unit and integration tests added
Signed-off-by: WojciechowskiPiotr <devel@it-playground.pl>
2021-02-09 21:37:26 +01:00
Sebastiaan van Stijn 1757c974fa docker/api/image: replace use of deprecated "filter" argument
The "filter" argument was deprecated in docker 1.13 (API version 1.25),
and removed from API v1.41 and up. See https://github.com/docker/cli/blob/v20.10.0-rc1/docs/deprecated.md#filter-param-for-imagesjson-endpoint

This patch applies the name as "reference" filter, instead of "filter" for API
1.25 and up.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-11-26 17:07:27 +00:00
aiordache f5531a94e1 Fix ssh connection - don't override the host and port of the http pool
Signed-off-by: aiordache <anca.iordache@docker.com>
2020-11-18 14:44:24 +01:00
Mariano Scazzariello bb1c528ab3
Add max_pool_size parameter (#2699)
* Add max_pool_size parameter

Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>

* Add client version to tests

Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>

* Fix parameter position

Signed-off-by: Mariano Scazzariello <marianoscazzariello@gmail.com>
2020-11-17 15:42:36 +01:00
Anca Iordache daa9f179c3
Merge pull request #2671 from aiordache/default_tag
Set image default tag on pull
2020-10-16 11:35:16 +02:00
aiordache 180414dcbb Shell out to SSH client for an ssh connection
Signed-off-by: aiordache <anca.iordache@docker.com>
2020-10-13 10:42:38 +02:00
aiordache cec152db5f Set image default tag on pull
Signed-off-by: aiordache <anca.iordache@docker.com>
2020-09-16 17:36:50 +02:00
aiordache c7c5b551fc set engine version for unit tests to avoid querying the engine
Signed-off-by: aiordache <anca.iordache@docker.com>
2020-08-20 15:29:24 +02:00
Anca Iordache 2c522fb362
Fix memory conversion to bytes (#2645)
* Fix memory conversion to bytes

Co-authored-by: Ulysses Souza <ulysses.souza@gmail.com>

Signed-off-by: aiordache <anca.iordache@docker.com>
2020-08-17 18:32:48 +02:00
Sebastiaan van Stijn 0be75d54ca Update credentials-helpers to v0.6.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-08-10 19:14:00 +02:00
Anca Iordache 6367bbee2e
Merge pull request #2520 from Nicceboy/master
Disable compression by default when using container:get_archive method
2020-08-07 14:42:58 +02:00
Ville Skyttä 631abd156a
Spelling fixes (#2571)
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2020-08-07 14:33:19 +02:00
Lucidiot dd0450a14c
Add device requests (#2471)
* Add DeviceRequest type

Signed-off-by: Erwan Rouchet <rouchet@teklia.com>

* Add device_requests kwarg in host config

Signed-off-by: Erwan Rouchet <rouchet@teklia.com>

* Add unit test for device requests

Signed-off-by: Erwan Rouchet <rouchet@teklia.com>

* Fix unit test

Signed-off-by: Erwan Rouchet <rouchet@teklia.com>

* Use parentheses for multiline import

Signed-off-by: Erwan Rouchet <rouchet@teklia.com>

* Create 1.40 client for device-requests test

Signed-off-by: Laurie O <laurie_opperman@hotmail.com>

Co-authored-by: Laurie O <laurie_opperman@hotmail.com>
Co-authored-by: Bastien Abadie <abadie@teklia.com>
2020-08-07 13:58:35 +02:00
Sebastiaan van Stijn 26d8045ffa Fix CreateContainerTest.test_invalid_log_driver_raises_exception
This test was updated in 7d92fbdee1, but
omitted the "error" prefix in the message, causing the test to fail;

    _________ CreateContainerTest.test_invalid_log_driver_raises_exception _________
    tests/integration/api_container_test.py:293: in test_invalid_log_driver_raises_exception
        assert excinfo.value.explanation in expected_msgs
    E   AssertionError: assert 'error looking up logging plugin asdf: plugin "asdf" not found' in ["logger: no log driver named 'asdf' is registered", 'looking up logging plugin asdf: plugin "asdf" not found']
    E    +  where 'error looking up logging plugin asdf: plugin "asdf" not found' = APIError(HTTPError('400 Client Error: Bad Request for url: http+docker://localhost/v1.39/containers/create')).explanation
    E    +    where APIError(HTTPError('400 Client Error: Bad Request for url: http+docker://localhost/v1.39/containers/create')) = <ExceptionInfo APIError tblen=6>.value

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-07-17 15:59:12 +02:00
Ulysses Souza 74a0734d37
Merge pull request #2551 from haboustak/2550-add-driveropts-to-endpointconfig
Add support for DriverOpts in EndpointConfig
2020-07-02 10:51:35 +02:00
aiordache 7133916798 add test for context load without orchestrator
Signed-off-by: aiordache <anca.iordache@docker.com>
2020-06-02 10:50:03 +02:00
Ulysses Souza 3ce2d8959d Specify when to use `tls` on Context constructor
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2020-05-28 20:53:45 +02:00
Mike Haboustak df7bf5f5e0
Add support for DriverOpts in EndpointConfig
Docker API 1.32 added support for providing options to a network driver
via EndpointConfig when connecting a container to a network.

Signed-off-by: Mike Haboustak <haboustak@gmail.com>
2020-04-30 05:27:45 -04:00
Wilson Júnior 7d92fbdee1
Fix tests to support both log plugin feedbacks
Signed-off-by: Wilson Júnior <wilsonpjunior@gmail.com>
Docker-DCO-1.1-Signed-off-by: Wilson Júnior <wilsonpjunior@gmail.com> (github: wpjunior)
2020-04-21 17:00:48 -03:00
Niklas Saari 51fd6dd1ce
Disable compression by default when using get_archive method
Signed-off-by: Niklas Saari <niklas.saari@tutanota.com>
2020-02-26 23:09:38 +02:00
Sebastiaan van Stijn da90bb3259
xfail "docker top" tests, and adjust for alpine image
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-17 10:25:53 +01:00
Anca Iordache 64fdb32ae8 Implement context management, lifecycle and unittests.
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2020-02-05 14:49:42 +01:00
Sebastiaan van Stijn 940805dde6
Fix ImageCollectionTest.test_pull_multiple flakiness
The ImageCollectionTest.test_pull_multiple test performs a `docker pull` without
a `:tag` specified) to pull all tags of the given repository (image).

After pulling the image, the image(s) pulled are checked to verify if the list
of images contains the `:latest` tag.

However, the test assumes that all tags of the image are tags for the same
version of the image (same digest), and thus a *single* image is returned, which
is not always the case.

Currently, the `hello-world:latest` and `hello-world:linux` tags point to a
different digest, therefore the `client.images.pull()` returns multiple images:
one image for digest, making the test fail:

    =================================== FAILURES ===================================
    ____________________ ImageCollectionTest.test_pull_multiple ____________________
    tests/integration/models_images_test.py:90: in test_pull_multiple
        assert len(images) == 1
    E   AssertionError: assert 2 == 1
    E    +  where 2 = len([<Image: 'hello-world:linux'>, <Image: 'hello-world:latest'>])

This patch updates the test to not assume a single image is returned, and instead
loop through the list of images and check if any of the images contains the
`:latest` tag.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-01-06 13:46:23 +01:00
Yuval Goldberg 656db96b4a Fix mac_address connect usage in network functions && addind appropriate test
Signed-off-by: Yuval Goldberg <yuvigoldi@hotmail.com>
2019-12-19 15:43:03 +02:00
Sebastiaan van Stijn 53469e0dd3
Fix broken test due to BUSYBOX -> TEST_IMG rename
The BUSYBOX variable was renamed to TEST_IMG in
54b48a9b7a, however
0ddf428b6c got merged
after that change, but was out of date, and therefore
caused the tests to fail:

```
=================================== FAILURES ===================================
________ ServiceTest.test_create_service_with_network_attachment_config ________
tests/integration/api_service_test.py:379: in test_create_service_with_network_attachment_config
    container_spec = docker.types.ContainerSpec(BUSYBOX, ['true'])
E   NameError: global name 'BUSYBOX' is not defined
```

Fix the test by using the correct variable name.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-30 00:14:20 +02:00
Joffrey F 8fea5738d3
Merge pull request #2333 from hannseman/network-attachment-config
Add NetworkAttachmentConfig for service create/update
2019-08-27 00:21:27 -07:00
Joffrey F 5660730d36
Merge pull request #2383 from thaJeztah/support_mirrors
test/Dockerfile: allow using a mirror for the apt repository
2019-08-27 00:16:00 -07:00
Joffrey F 1c36417d8f
Merge pull request #2401 from fluetm/fix-osxkeychain-issue
Fix for empty auth keys in config.json
2019-08-26 11:11:32 -07:00
Matt Fluet aa13df40b1 Fix for empty auth keys in config.json
Signed-off-by: Matt Fluet <matt.fluet@appian.com>
2019-08-15 18:15:57 -04:00
Sebastiaan van Stijn 54b48a9b7a
Update alpine version to 3.10, and rename BUSYBOX variable
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-10 19:11:58 +02:00
Joffrey F 17c86429e4
Merge pull request #2382 from thaJeztah/fix_platform_tests
Adjust `--platform` tests for changes in docker engine
2019-07-18 22:49:54 -07:00
Joffrey F b20b10cac4
Merge pull request #2380 from thaJeztah/xfail_test_init_swarm_data_path_addr
xfail test_init_swarm_data_path_addr
2019-07-18 22:47:21 -07:00
Sebastiaan van Stijn b2a1b03163
Update credentials-helpers to v0.6.3
full diff:
https://github.com/docker/docker-credential-helpers/compare/v0.6.2...v0.6.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-17 10:54:08 +02:00
Sebastiaan van Stijn 5a91c2e83e
test/Dockerfile: allow using a mirror for the apt repository
With this change applied, the default debian package repository can be
replaced with a mirror;

```
make APT_MIRROR=cdn-fastly.deb.debian.org build-py3

...

Step 5/19 : RUN apt-get update && apt-get -y install     gnupg2     pass     curl
 ---> Running in 01c1101a0bd0
Get:1 http://cdn-fastly.deb.debian.org/debian buster InRelease [118 kB]
Get:2 http://cdn-fastly.deb.debian.org/debian-security buster/updates InRelease [39.1 kB]
Get:3 http://cdn-fastly.deb.debian.org/debian buster-updates InRelease [46.8 kB]
Get:4 http://cdn-fastly.deb.debian.org/debian buster/main amd64 Packages [7897 kB]
Get:5 http://cdn-fastly.deb.debian.org/debian-security buster/updates/main amd64 Packages [22.8 kB]
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-16 12:51:01 +02:00
Sebastiaan van Stijn bc46490a68
Adjust `--platform` tests for changes in docker engine
These tests started failing on recent versions of the engine because the error string changed,
and due to a regression, the status code for one endpoint changed from a 400 to a 500.

On Docker 18.03:

The `docker build` case properly returns a 400, and "invalid platform" as error string;

```bash
docker build --platform=foobar -<<EOF
FROM busybox
EOF

Sending build context to Docker daemon  2.048kB
Error response from daemon: invalid platform: invalid platform os "foobar"
```

```
DEBU[2019-07-15T12:17:22.745511870Z] Calling GET /_ping
DEBU[2019-07-15T12:17:22.748224796Z] Calling POST /session
DEBU[2019-07-15T12:17:22.748692282Z] Calling POST /v1.37/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&platform=foobar&rm=1&session=d7b6ceba9d8d0aed67a805528554feb5285781fe888a4bf4e0c15cb09bffd614&shmsize=0&target=&ulimits=null
```

The `docker pull --platform=foobar hello-world:latest` case incorrectly returns a 500

```
DEBU[2019-07-15T12:16:08.744827612Z] Calling POST /v1.37/images/create?fromImage=hello-world&platform=foobar&tag=latest
DEBU[2019-07-15T12:16:08.745594874Z] FIXME: Got an API for which error does not match any expected type!!!: invalid platform: invalid platform os "foobar"  error_type="*errors.errorString" module=api
ERRO[2019-07-15T12:16:08.745916686Z] Handler for POST /v1.37/images/create returned error: invalid platform: invalid platform os "foobar"
DEBU[2019-07-15T12:16:08.746191172Z] FIXME: Got an API for which error does not match any expected type!!!: invalid platform: invalid platform os "foobar"  error_type="*errors.errorString" module=api
```

On Docker 18.09;

```bash
docker build --platform=foobar -<<EOF
FROM busybox
EOF

Error response from daemon: "foobar": unknown operating system or architecture: invalid argument
```

Which incorrectly returns a 500 status;

```
DEBU[2019-07-15T11:59:20.687268380Z] Calling POST /v1.39/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&platform=foobar&rm=1&session=jko7kejjvs93judyfnq7shoda&shmsize=0&target=&ulimits=null&version=1
DEBU[2019-07-15T11:59:20.687282279Z] Calling POST /session
INFO[2019-07-15T11:59:20.687761392Z] parsed scheme: ""                             module=grpc
INFO[2019-07-15T11:59:20.687833668Z] scheme "" not registered, fallback to default scheme  module=grpc
INFO[2019-07-15T11:59:20.688017578Z] ccResolverWrapper: sending new addresses to cc: [{ 0  <nil>}]  module=grpc
INFO[2019-07-15T11:59:20.688270160Z] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2019-07-15T11:59:20.688353083Z] pickfirstBalancer: HandleSubConnStateChange: 0xc4209b0630, CONNECTING  module=grpc
INFO[2019-07-15T11:59:20.688985698Z] pickfirstBalancer: HandleSubConnStateChange: 0xc4209b0630, READY  module=grpc
DEBU[2019-07-15T11:59:20.812700550Z] client is session enabled
DEBU[2019-07-15T11:59:20.813139288Z] FIXME: Got an API for which error does not match any expected type!!!: invalid argument
github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs.init
	/go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs/errors.go:40
github.com/docker/docker/vendor/github.com/containerd/containerd/content.init
	<autogenerated>:1
github.com/docker/docker/builder/builder-next.init
	<autogenerated>:1
github.com/docker/docker/api/server/backend/build.init
	<autogenerated>:1
main.init
	<autogenerated>:1
runtime.main
	/usr/local/go/src/runtime/proc.go:186
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:2361  error_type="*errors.fundamental" module=api
ERRO[2019-07-15T11:59:20.813210677Z] Handler for POST /v1.39/build returned error: "foobar": unknown operating system or architecture: invalid argument
DEBU[2019-07-15T11:59:20.813276737Z] FIXME: Got an API for which error does not match any expected type!!!: invalid argument
github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs.init
	/go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs/errors.go:40
github.com/docker/docker/vendor/github.com/containerd/containerd/content.init
	<autogenerated>:1
github.com/docker/docker/builder/builder-next.init
	<autogenerated>:1
github.com/docker/docker/api/server/backend/build.init
	<autogenerated>:1
main.init
	<autogenerated>:1
runtime.main
	/usr/local/go/src/runtime/proc.go:186
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:2361  error_type="*errors.fundamental" module=api
```

Same for the `docker pull --platform=foobar hello-world:latest` case:

```bash
docker pull --platform=foobar hello-world:latest
Error response from daemon: "foobar": unknown operating system or architecture: invalid argument
```

```
DEBU[2019-07-15T12:00:18.812995330Z] Calling POST /v1.39/images/create?fromImage=hello-world&platform=foobar&tag=latest
DEBU[2019-07-15T12:00:18.813229172Z] FIXME: Got an API for which error does not match any expected type!!!: invalid argument
github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs.init
	/go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs/errors.go:40
github.com/docker/docker/vendor/github.com/containerd/containerd/content.init
	<autogenerated>:1
github.com/docker/docker/builder/builder-next.init
	<autogenerated>:1
github.com/docker/docker/api/server/backend/build.init
	<autogenerated>:1
main.init
	<autogenerated>:1
runtime.main
	/usr/local/go/src/runtime/proc.go:186
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:2361  error_type="*errors.fundamental" module=api
ERRO[2019-07-15T12:00:18.813365546Z] Handler for POST /v1.39/images/create returned error: "foobar": unknown operating system or architecture: invalid argument
DEBU[2019-07-15T12:00:18.813461428Z] FIXME: Got an API for which error does not match any expected type!!!: invalid argument
github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs.init
	/go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs/errors.go:40
github.com/docker/docker/vendor/github.com/containerd/containerd/content.init
	<autogenerated>:1
github.com/docker/docker/builder/builder-next.init
	<autogenerated>:1
github.com/docker/docker/api/server/backend/build.init
	<autogenerated>:1
main.init
	<autogenerated>:1
runtime.main
	/usr/local/go/src/runtime/proc.go:186
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:2361  error_type="*errors.fundamental" module=api
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-15 15:48:06 +02:00
Sebastiaan van Stijn 6f6572bb8a
Update to python 3.7 (buster) and use build-args
The build arg can be used to either test different versions, but
also makes it easier to "grep" when upgrading versions.

The output format of `gpg2 --list-secret-keys` changed in the version
installed on Buster, so `grep` was replaced with `awk` to address
the new output format;

Debian Jessie:

    gpg2 --no-auto-check-trustdb --list-secret-keys
    /root/.gnupg/secring.gpg
    ------------------------
    sec   1024D/A7B21401 2018-04-25
    uid                  Sakuya Izayoi <sakuya@gensokyo.jp>
    ssb   1024g/C235E4CE 2018-04-25

Debian Buster:

    gpg2 --no-auto-check-trustdb --list-secret-keys
    /root/.gnupg/pubring.kbx
    ------------------------
    sec   dsa1024 2018-04-25 [SCA]
          9781B87DAB042E6FD51388A5464ED987A7B21401
    uid           [ultimate] Sakuya Izayoi <sakuya@gensokyo.jp>
    ssb   elg1024 2018-04-25 [E]

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-15 13:27:07 +02:00
Sebastiaan van Stijn 1126ea9d6f
xfail test_init_swarm_data_path_addr
This test can fail if `eth0` has multiple IP addresses;

   E   docker.errors.APIError: 400 Client Error: Bad Request ("interface eth0 has more than one IPv6 address (2001:db8:1::242:ac11:2 and fe80::42:acff:fe11:2)")

Which is not a failiure, but depends on the environment that
the test is run in.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-12 22:50:35 +02:00
Sebastiaan van Stijn df340bea60
Update credentials-helpers to v0.6.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-12 01:28:41 +02:00
Michael Crosby 8303884612 Remove exec detach test
Forking off an exec process and detaching isn't a supported method

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-06-25 13:08:39 -04:00
Ulysses Souza ccd9ca4947 Xfail test_attach_stream_and_cancel on TLS
This test is quite flaky on ssl integration test

Signed-off-by: Ulysses Souza <ulysses.souza@docker.com>
2019-05-18 19:33:48 -07:00
Hannes Ljungberg 0ddf428b6c Add NetworkAttachmentConfig type
Signed-off-by: Hannes Ljungberg <hannes@5monkeys.se>
2019-05-03 22:27:32 +02:00
Joffrey F 87ee18aa39 Change use_config_proxy default value to True to match CLI behavior
Signed-off-by: Joffrey F <joffrey@docker.com>
2019-05-01 20:52:01 -07:00
Joffrey F 836194c64f
Merge pull request #2295 from hannseman/swarm-rotate-token
Add support for rotate_manager_unlock_key
2019-05-01 20:36:45 -07:00
Joffrey F 75e0ad017c
Merge pull request #2328 from docker/modernize_test_deps
Update some test dependencies / default values with newer versions
2019-05-01 02:48:05 -07:00
Hannes Ljungberg 532c62ee51 Add support for rotate_manager_unlock_key
Signed-off-by: Hannes Ljungberg <hannes@5monkeys.se>
2019-05-01 11:45:20 +02:00
Joffrey F eba8345c37 Update some test dependencies / default values with newer versions
Signed-off-by: Joffrey F <joffrey@docker.com>
2019-05-01 02:36:19 -07:00
Joffrey F 4d62dd0a64
Merge pull request #2296 from hannseman/swarm-init-response
Return node id on swarm init
2019-05-01 02:29:30 -07:00
Joffrey F 9682422718
Merge pull request #2303 from hannseman/swarm-DataPathAddr
Add support for swarm DataPathAddr
2019-05-01 02:22:06 -07:00
Joffrey F cc13b82e9f
Merge pull request #2222 from docker/vendor_dockerpycreds
Make dockerpycreds part of the SDK under docker.credentials
2019-05-01 01:39:54 -07:00
Hannes Ljungberg 110c6769c9 Add test for join on already joined swarm
Signed-off-by: Hannes Ljungberg <hannes@5monkeys.se>
2019-05-01 10:24:50 +02:00
Hannes Ljungberg c7b9cae0a0 Add swarm support for data_addr_path
Signed-off-by: Hannes Ljungberg <hannes@5monkeys.se>
2019-05-01 10:24:50 +02:00