GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: create container with a non-existing volume driver triggers docker pull by thaJeztah · Pull Request #48773 · moby/moby

Conversation

@thaJeztah

@thaJeztah thaJeztah commented Oct 26, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • fixes creating a container with a non-existing volume driver triggers a docker pull #48772

fix: create container with a non-existing volume driver triggers docker pull

The docker CLI uses a "not found" (404) response on docker create and docker run
as indication that the specified image doesn't exist. Currently, specifying a
volume-driver that is not found also returns a "not found" error, resulting in
the image to be pulled, even if it already exists.

To reproduce:

Pull the image to make sure it's present;

docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
Digest: sha256:768e5c6f5cb6db0794eec98dc7a967f40631746c32232b78a3105fb946f3ab83
Status: Image is up to date for busybox:latest
docker.io/library/busybox:latest

Before this patch, an image pull was triggered;

docker run --rm --volume-driver nosuchdriver -v /something busybox
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
Digest: sha256:768e5c6f5cb6db0794eec98dc7a967f40631746c32232b78a3105fb946f3ab83
Status: Image is up to date for busybox:latest
docker: Error response from daemon: create 0f4f0e066f5e10b5de0fd794e4e28dc7b5e496d68af291df6c6204a06fbe1599: error looking up volume plugin nosuchdriver: plugin "nosuchdriver" not found.
See 'docker run --help'.

Same, but using the --mount flag;

docker run  --rm --mount=type=volume,volume-driver=nosuchdriver,target=/something busybox
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
Digest: sha256:768e5c6f5cb6db0794eec98dc7a967f40631746c32232b78a3105fb946f3ab83
Status: Image is up to date for busybox:latest
docker: Error response from daemon: create e80e831b8e1db83febdc4af534d33607face62d8e661de1eeb3ed8b7d4ab5c47: error looking up volume plugin nosuchdriver: plugin "nosuchdriver" not found.
See 'docker run --help'.

After this patch, no pull happens, and the error is returned about the missing
driver;

docker run --rm --volume-driver nosuchdriver -v /something busybox
docker: Error response from daemon: create 21890da7f789fa4e8ce3864284b4c62c3e387373c44c35238048d4e05d17999e: error looking up volume plugin something: plugin "nosuchdriver" not found.
See 'docker run --help'.

docker run  --rm --mount=type=volume,volume-driver=nosuchdriver,target=/something busybox
docker: Error response from daemon: create 21890da7f789fa4e8ce3864284b4c62c3e387373c44c35238048d4e05d17999e: error looking up volume plugin something: plugin "nosuchdriver" not found.
See 'docker run --help'.

volume/drivers: Store.lookup: touch-up error for looking up plugins

The error was duplicating the name of the plugin, showing it twice;

Before this patch:

Error response from daemon: create new-volume: error looking up volume plugin this-plugin-does-not-exist: plugin "this-plugin-does-not-exist" not found

After this patch:

Error response from daemon: create new-volume: error looking up volume plugin: plugin "this-plugin-does-not-exist" not found

volume/service: VolumeStore.create: remove redundant check

We already checked whether driverName was empty above, in which case
we try if there's a driver providing the volume and return early. We
only need to set the default driver if no volume was found in that branch
so let's move this code there.

- How to verify it

A test was added to verify the behavior:

make TEST_FILTER='TestContainerVolumeInvalidDriver' TEST_SKIP_INTEGRATION_CLI=1 DOCKER_GRAPHDRIVER=vfs test-integration
=== RUN   TestContainerVolumeInvalidDriver
=== RUN   TestContainerVolumeInvalidDriver/new_volume
=== RUN   TestContainerVolumeInvalidDriver/conflicting_volume
--- PASS: TestContainerVolumeInvalidDriver (2.05s)
    --- PASS: TestContainerVolumeInvalidDriver/new_volume (1.02s)
    --- PASS: TestContainerVolumeInvalidDriver/conflicting_volume (1.03s)
PASS

- Description for the changelog

Fix a bug where creating a container with a volume that uses a non-existing driver causing an image-pull to be triggered.

- A picture of a cute animal (not mandatory but encouraged)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@thaJeztah thaJeztah added status/2-code-review area/plugins area/volumes Volumes kind/bugfix PR's that fix bugs labels Oct 26, 2024
@thaJeztah thaJeztah added this to the 28.0.0 milestone Oct 26, 2024
@thaJeztah thaJeztah self-assigned this Oct 26, 2024
@thaJeztah
thaJeztah requested a review from cpuguy83 October 26, 2024 20:28
@thaJeztah
thaJeztah force-pushed the fix_volume_pull branch from 993b958 to e1b3098 Compare October 26, 2024 20:33
cpuguy83
cpuguy83 requested changes Oct 26, 2024
View reviewed changes

@cpuguy83 cpuguy83 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be handled in the container API?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@thaJeztah

thaJeztah commented Oct 26, 2024

Copy link
Copy Markdown
Member Author

Hm, yeah, maybe; there's unfortunately multiple code paths I found that lead to this, and I was trying to find a central location to handle it. I can have a look how bad it is to put it in the other locations.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thaJeztah

thaJeztah commented Oct 26, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Hmm.. that said, looking at the docker-py test I'm wondering if we're returning the wrong status for volume create as well. At least a 404 doesn't seem right to me, and a 400 seems more correct for a driver that's not supported; https://github.com/docker/docker-py/blob/a8bac8822127a8f446893a4e7e60d4b5149333bf/tests/integration/api_volume_test.py#L19-L23

    def test_create_volume_invalid_driver(self):
        driver_name = 'invalid.driver'


        with pytest.raises(docker.errors.NotFound):
            self.client.create_volume('perfectcherryblossom', driver_name)
  • ☝️ opened integration: test_create_volume_invalid_driver allow either 400 or 404 docker/docker-py#3296 for that one
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thaJeztah thaJeztah mentioned this pull request Oct 27, 2024
integration: test_create_volume_invalid_driver allow either 400 or 404 docker/docker-py#3296
Merged
thaJeztah added 4 commits October 27, 2024 17:25
@thaJeztah
fix: create container with a non-existing volume driver triggers dock…
a0b87e9
…er pull

The docker CLI uses a "not found" (404) response on `docker create` and `docker run`
as indication that the specified image doesn't exist. Currently, specifying a
volume-driver that is not found also returns a "not found" error, resulting in
the image to be pulled, even if it already exists.

To reproduce:

Pull the image to make sure it's present;

    docker pull busybox
    Using default tag: latest
    latest: Pulling from library/busybox
    Digest: sha256:768e5c6f5cb6db0794eec98dc7a967f40631746c32232b78a3105fb946f3ab83
    Status: Image is up to date for busybox:latest
    docker.io/library/busybox:latest

Before this patch, an image pull was triggered;

    docker run --rm --volume-driver nosuchdriver -v /something busybox
    Unable to find image 'busybox:latest' locally
    latest: Pulling from library/busybox
    Digest: sha256:768e5c6f5cb6db0794eec98dc7a967f40631746c32232b78a3105fb946f3ab83
    Status: Image is up to date for busybox:latest
    docker: Error response from daemon: create 0f4f0e066f5e10b5de0fd794e4e28dc7b5e496d68af291df6c6204a06fbe1599: error looking up volume plugin nosuchdriver: plugin "nosuchdriver" not found.
    See 'docker run --help'.

Same, but using the `--mount` flag;

    docker run  --rm --mount=type=volume,volume-driver=nosuchdriver,target=/something busybox
    Unable to find image 'busybox:latest' locally
    latest: Pulling from library/busybox
    Digest: sha256:768e5c6f5cb6db0794eec98dc7a967f40631746c32232b78a3105fb946f3ab83
    Status: Image is up to date for busybox:latest
    docker: Error response from daemon: create e80e831b8e1db83febdc4af534d33607face62d8e661de1eeb3ed8b7d4ab5c47: error looking up volume plugin nosuchdriver: plugin "nosuchdriver" not found.
    See 'docker run --help'.

After this patch, no pull happens, and the error is returned about the missing
driver;

    docker run --rm --volume-driver nosuchdriver -v /something busybox
    docker: Error response from daemon: create 21890da7f789fa4e8ce3864284b4c62c3e387373c44c35238048d4e05d17999e: error looking up volume plugin something: plugin "nosuchdriver" not found.
    See 'docker run --help'.

    docker run  --rm --mount=type=volume,volume-driver=nosuchdriver,target=/something busybox
    docker: Error response from daemon: create 21890da7f789fa4e8ce3864284b4c62c3e387373c44c35238048d4e05d17999e: error looking up volume plugin something: plugin "nosuchdriver" not found.
    See 'docker run --help'.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
volume/drivers: Store.lookup: touch-up error for looking up plugins
7543ab0
The error was duplicating the name of the plugin, showing it twice;

Before this patch:

    Error response from daemon: create new-volume: error looking up volume plugin this-plugin-does-not-exist: plugin "this-plugin-does-not-exist" not found

After this patch:

    Error response from daemon: create new-volume: error looking up volume plugin: plugin "this-plugin-does-not-exist" not found

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
volume/service: VolumeStore.create: remove redundant check
818b36a
We already checked whether driverName was empty above, in which case
we try if there's a driver providing the volume and return early. We
only need to set the default driver if no volume was found in that branch
so let's move this code there.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
WIP: move error-conversion to container API
c3fc2f9
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
thaJeztah force-pushed the fix_volume_pull branch from e1b3098 to c3fc2f9 Compare October 27, 2024 16:25
@thaJeztah
thaJeztah marked this pull request as draft October 27, 2024 16:25
@thaJeztah thaJeztah modified the milestones: 28.0.0, 29.0.0 Jan 17, 2025
@thaJeztah thaJeztah modified the milestones: 29.0.0, 29.1.0 Jul 14, 2025
@vvoland vvoland modified the milestones: 29.1.0, v-future Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cpuguy83 cpuguy83 cpuguy83 requested changes

Requested changes must be addressed to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@thaJeztah thaJeztah

Labels

area/plugins area/volumes Volumes kind/bugfix PR's that fix bugs status/2-code-review

Projects

None yet

Milestone

v-future

Development

Successfully merging this pull request may close these issues.

creating a container with a non-existing volume driver triggers a docker pull

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@thaJeztah @cpuguy83 @vvoland
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.