Skip to content

[Bug]: Build failing with absolute context directory and Dockerfile. #588

@jglogan

Description

@jglogan

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

/tmp/foo/Dockerfile:

FROM docker.io/library/python:slim
WORKDIR /app
COPY index.html /app/
EXPOSE 8080
CMD ["python", "-m", "http.server", "--bind", "0.0.0.0", "8080"]

/tmp/foo/index.html:

<!DOCTYPE html><head><title>hello</title></head><body><p>hello</p></body></html>

Run:

container build -t test -f /tmp/foo/Dockerfile /tmp/foo 

Current behavior

% container build -t test -f "/tmp/foo/Dockerfile" /tmp/foo 
[+] Building 1.0s (6/6) FINISHED                                                                                                                                                                                                                                 
 => [resolver] fetching image...docker.io/library/python:slim                                                                                                                                                                                               0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                                                                                                             0.0s
 => oci-layout://docker.io/library/python:slim@sha256:8ebd0ea12eea7d353861db137baa7be7bac116537f85e50bd84a52633e302265                                                                                                                                      0.0s
 => => resolve docker.io/library/python:slim@sha256:8ebd0ea12eea7d353861db137baa7be7bac116537f85e50bd84a52633e302265                                                                                                                                        0.0s
 => [internal] load build context                                                                                                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                                                                                                             0.0s
 => CACHED [linux/arm64/v8 1/3] WORKDIR /app                                                                                                                                                                                                                0.0s
 => ERROR [linux/arm64/v8 2/3] COPY index.html /app/                                                                                                                                                                                                        0.0s
------
 > [linux/arm64/v8 2/3] COPY index.html /app/:
------
Error: unknown (2): failed to solve: failed to compute cache key: failed to calculate checksum of ref o8xufenjszlv3y2kb16baxehq::96w17nv5k4keim82uo4lgjht5: "/index.html": not found

Going to the build directory and using context . works:

% cd /tmp/foo
% container build -t test -f Dockerfile .  
[+] Building 1.2s (7/7) FINISHED                                                                                                                                                                                                                                 
 => [resolver] fetching image...docker.io/library/python:slim                                                                                                                                                                                               0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                                                                                                             0.0s
 => oci-layout://docker.io/library/python:slim@sha256:8ebd0ea12eea7d353861db137baa7be7bac116537f85e50bd84a52633e302265                                                                                                                                      0.0s
 => => resolve docker.io/library/python:slim@sha256:8ebd0ea12eea7d353861db137baa7be7bac116537f85e50bd84a52633e302265                                                                                                                                        0.0s
 => [internal] load build context                                                                                                                                                                                                                           0.0s
 => => transferring context: 116B                                                                                                                                                                                                                           0.0s
 => CACHED [linux/arm64/v8 1/3] WORKDIR /app                                                                                                                                                                                                                0.0s
 => [linux/arm64/v8 2/3] COPY index.html /app/                                                                                                                                                                                                              0.0s
 => exporting to oci image format                                                                                                                                                                                                                           0.3s
 => => exporting layers                                                                                                                                                                                                                                     0.0s
 => => exporting manifest sha256:ffb5d507ed2299b8cd2ee240e628da3dc5103baebef9bc0ec76691394c82cbcc                                                                                                                                                           0.0s
 => => exporting config sha256:e7751636ae9a340ec91571f183cd531971ca03275ee61313174838dfd2ea88f4                                                                                                                                                             0.0s
 => => exporting manifest list sha256:47081a8a539c0720d4c0113b26be9e11edd4210aba963fe187bdd431fe035b40                                                                                                                                                      0.0s
 => => sending tarball                                                                                                                                                                                                                                      0.2s
Successfully built test:latest                                           

Expected behavior

Both build command forms succeed.

Environment

- OS: 26 beta
- Xcode: 26 beta
- Container: 0.4.1

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Labels

nextItems in scope for the next few milestones

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions