Skip to content

fix(sandbox): Pull the sandbox image before container creation #2554

Closed

Description

@dan-petty

Problem Description

devops sandbox deploy fails when the sandbox image is not on the local engine. It does not pull the image, and the error is the raw Docker API reply. The default image is python:3.14-slim, so the first deploy on a fresh engine fails.

DockerEngineService creates the container with containers.create (src/devops_cli/docker/engine.py), and no code under src/devops_cli/sandbox/ or src/devops_cli/docker/ pulls an image first.

Reproduction Steps

  1. Make sure the engine has no python:3.14-slim image.
  2. Run uv run devops sandbox deploy --name check --network-mode isolated.

Expected vs Actual Behavior

  • Expected: the command pulls the image (or, if the design refuses pulls, stops with a message that names the image and the command that pulls it), then deploys.
  • Actual: ✗ Failed deploying sandbox: Failed deploying sandbox container: Container creation failed: 404 Client Error for http+docker://localhost/v1.56/containers/create: Not Found ("No such image: python:3.14-slim"), exit 1.

Environment Diagnostics

  • devops-cli on origin/main d156ce7 (2026-10-28).
  • Docker Engine 29.9.2, docker SDK 7.2.0.

Logs, Traces, or Terminal Output

After docker pull python:3.14-slim, the same deploy works, and devops sandbox logs returns stdout and stderr apart (#2520).

Existing Tool Considered

The docker SDK has images.pull, and containers.run pulls a missing image itself. Nothing new is built.

Proposed design

Problem statement

devops sandbox deploy fails with a raw Docker API 404 error when the sandbox image is not on the local engine. The command does not pull the image before it creates the container. The first deploy on a fresh engine always fails. The default image is python:3.14-slim.

Acceptance criteria

Requirement: Pull missing image before container creation

When the sandbox image is not present on the local engine, the deploy command SHALL pull the image before it creates the container.

Scenario: Deploy with a missing image

  • WHEN The engine has no image matching the sandbox image reference
  • THEN The command pulls the image and then creates the container without a 404 error

Requirement: Skip pull when image exists locally

When the sandbox image is already present on the local engine, the deploy command SHALL NOT issue a registry pull request.

Scenario: Deploy with an existing image

  • WHEN The engine already has an image matching the sandbox image reference
  • THEN The command creates the container without a network pull call

Requirement: Name the image in a pull failure error

When the image pull fails, the error message SHALL contain the image reference and the reason for the failure.

Scenario: Pull fails due to a registry error

  • WHEN The image pull fails because the registry is unreachable or the image does not exist in the registry
  • THEN The error message contains the image reference and the failure reason

Existing Tool Considered

docker-py (v7.2.0, already a project dependency) provides client.images.pull(repository, tag) to pull an image and client.images.get(name) to check if one exists locally. The project wraps the SDK through DockerEngineService but does not call either method in the sandbox deploy path. The fix adds one pull_image method to DockerEngineService and calls it from the sandbox deploy code. No new library is introduced.

Key questions

  • Where should the pull happen: inside DockerEngineService.create_container or in the sandbox deploy caller?: In the sandbox deploy caller, before it calls create_container. (best practice) [sources: src/devops_cli/docker/engine.py]
    • Rejected: Pull inside DockerEngineService.create_container. Rejected. This would add a network check to every container creation, including callers that use locally-built images.
    • Chosen: Pull in the sandbox deploy caller before create_container. Chosen. The sandbox deploy is the path that needs a registry image. The pull is scoped to where it is needed.
    • Rejected: Replace containers.create with containers.run. Rejected. containers.run starts the container immediately, which changes the create-then-start flow the sandbox deploy uses.
  • Should the code check if the image exists locally before pulling?: Yes. Check with images.get first. Pull only when the image is absent. (best practice) [sources: src/devops_cli/docker/engine.py]
    • Rejected: Always pull. Rejected. A pull makes a network request even when the image is local, adding latency to every deploy.
    • Chosen: Check locally then pull if absent. Chosen. The image is local in the common case. A local check avoids the network round-trip.
  • What is the default sandbox image reference?: python:3.14-slim [sources: src/devops_cli/docker/sandbox.py]
  • Does the DockerEngineFake in tests already support a pull call?: The fake holds alpine:3 and scripts container behavior. It does not record a pull call. The test for this fix must add a pull call to the fake and assert it is called when the image is absent. [sources: docs/TESTING.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/medium
    effort/low
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The deploy command fails on a fresh engine because it does not pull the image, which is a defect in the existing flow.
    • Priority: P2-Medium. It blocks the first deploy on a fresh engine, but a manual docker pull is a workaround.
    • Value: Medium. It removes a first-use failure for every new user who has not pre-pulled the default image.
    • Effort: Low. The fix is one images.pull call before containers.create, or a clearer error message naming the image.
    • Related: fix(sandbox): devops sandbox logs fails on a real Docker engine because the docker SDK's logs call takes no demux argument #2520, which asks for a different change. Both fix a sandbox command that fails on a real Docker engine in the same service file, but #2520 fixes the logs call while this fixes the deploy call.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 29, 2026
  5. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 0f7bc26 (see proposed design in issue body).

  6. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/2554-devops-sandbox-deploy-fails-with-a, draft pull request #2996. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Add pull_image to DockerEngineService: 3450 tokens
    2. Add image pull support to DockerEngineFake: 3372 tokens
    3. Pull image in sandbox deploy before create: 3381 tokens
  7. added a commit that references this issue on Nov 1, 2026
  8. added
    status/planned
    owner/service
    and removed
    status/ready
    on Nov 1, 2026
  9. 94 remaining items

  10. added
    status/blocked
    and removed
    status/in-progress
    on Nov 5, 2026
  11. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261104-235519-dd3d ended: succeeded.
    Image digest: sha256:b161a617dc04fdc13d2c96b33b2a4acbfe6bebfae21942588aa7201250eb6e29

    The last lines of its log:

    Tool call: shell, program uv, ok.
    Tool call: edit_file, retry (old_text not found in src/devops_cli/docker/engine.py. No changes were written.).
    Tool call: shell, started: uv run ruff check --fix --select=<masked> ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: cd /home/devops/.data/agent/worktrees/w-2554 && python -c <masked>
    Tool call: shell, program cd, refused.
    Tool call: shell, started: cd /home/devops/.data/agent/worktrees/w-2554 && find . -name ...
    Tool call: shell, program cd, refused.
    Tool call: shell, started: find . -name *.py | xargs ...
    Tool call: shell, program find, refused.
    Tool call: shell, started: find . -name *.py -exec grep ...
    Tool call: shell, program find, refused.
    Tool call: shell, started: ls -la src/devops_cli/docker/engine.py
    Tool call: shell, program ls, ok.
    Tool call: shell, started: cd /home/devops/.data/agent/worktrees/w-2554 && git diff --name-only
    Tool call: shell, program cd, refused.
    Tool call: shell, started: cd /home/devops/.data/agent/worktrees/w-2554 && echo <masked>
    Tool call: shell, program cd, refused.
    Tool call: edit_file, retry (old_text not found in tests/support/docker_engine_scenarios.py. No changes were written.).
    Tool call: edit_file, retry (old_text not found in tests/sandbox/test_sandbox_deploy_pull.py. No changes were written.).
    Tool call: shell, started: grep -n ABSENT_IMAGE\\|absent_image tests/support/docker_engine_scenarios.py
    Tool call: shell, program grep, refused.
    Tool call: shell, started: grep -n ABSENT_IMAGE tests/support/docker_engine_scenarios.py
    Tool call: shell, program grep, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: cd /home/devops/.data/agent/worktrees/w-2554 && python -c <masked>
    Tool call: shell, program cd, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Restored the tasks.md of the change 2554-devops-sandbox-deploy-fails-with-a. A step only ticks the tasks of its own group.
    Tool call: edit_file, retry (old_text not found in tests/support/docker_engine_scenarios.py. No changes were written.).
    Tool call: shell, started: cd /home/devops/.data/agent/worktrees/w-2554 && git diff --name-only
    Tool call: shell, program cd, refused.
    Tool call: shell, started: git diff --name-only
    Tool call: shell, program git, ok.
    Tool call: shell, started: ls -la
    Tool call: shell, program ls, ok.
    Failure class lint. Action left: wait.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 38m 52s
    
  12. removed
    owner/service
    on Nov 5, 2026
  13. changed the title [-]fix(sandbox): devops sandbox deploy fails with a raw 404 when the sandbox image is not on the engine[/-] [+]fix(sandbox): Pull the sandbox image before container creation[/+] on Nov 6, 2026
  14. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 86 characters, and the limit is 60. The type and the scope stay.

    • Before: fix(sandbox): devops sandbox deploy fails with a raw 404 when the sandbox image is not on the engine
    • After: fix(sandbox): Pull the sandbox image before container creation
    • Source of the summary: the background model
  15. added
    status/in-progress
    status/in-review
    and removed
    status/blocked
    status/in-progress
    on Nov 10, 2026
  16. removed
    status/in-review
    on Nov 10, 2026
  17. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor
  18. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-10 20:48 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions