Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do "--cache-from" and "--cache-to" really require "--layers"? #24916

Open
flixman opened this issue Dec 30, 2024 · 0 comments
Open

Do "--cache-from" and "--cache-to" really require "--layers"? #24916

flixman opened this issue Dec 30, 2024 · 0 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@flixman
Copy link

flixman commented Dec 30, 2024

Issue Description

In the documentation for --cache-from and --cache-to is stated that --layers is required. However:

  1. ... I have observed that --layers default value is true
  2. ... I have run a couple of tests with and without --layers being set, and the results are the same: caches are reported to be used

without layers:

$ podman images --format "{{.Repository}}:{{.Tag}}" | grep 'registry.org/lists/builder' | xargs -r podman rmi
$ podman system prune -f
$ time podman build -f docker/lists/ci/Dockerfile -t registry.org/lists/lists:test --cache-from registry.org/lists/builder --cache-to registry.org/lists/builder .
STEP 1/4: FROM registry.org/lists/lists:acc
STEP 2/4: ADD requirements.dev.txt /tmp
--> Cache pulled from remote registry.org/lists/builder:95a4650b539ccea9d93d38c7d1ee6a7e80fa52e3d975097fe7e8af6b1db6053c:95a4650b539ccea9d93d38c7d1ee6a7e80fa52e3d975097fe7e8af6b1db6053c
--> Using cache 5a0e4396325023047038d3d49e7a68a03d35d33bb989136307b63bc148c4b965
--> 5a0e43963250
STEP 3/4: RUN --mount=type=cache,target=/root/.cache     apk add --no-cache --virtual devreqs gcc python3-dev musl-dev linux-headers &&     pip3 install -t /app/python_modules_test -r /tmp/requirements.dev.txt --no-compile &&     apk del devreqs
--> Cache pulled from remote registry.org/lists/builder:72229fe5ee2420647a548eb64a9cca511875b4c9f793fb990adbe7facaa1627f:72229fe5ee2420647a548eb64a9cca511875b4c9f793fb990adbe7facaa1627f
--> Using cache 265709f9d4506055aa03577e6bc0791ba2be165871259f39bb549ef3c1a5d6f2
--> 265709f9d450
STEP 4/4: ENV PYTHONPATH="${PYTHONPATH}:/app/python_modules_test" PATH="${PATH}:/app/python_modules_test/bin"
--> Using cache 76e6d4f2beace6f341d344243be60d64c273bfdaf66860b82eb3f6fa00ced83c
COMMIT registry.org/lists/lists:test
--> Pushing cache [registry.org/lists/builder]:894d3a64c54930b8cf90f268c16bf42684c57be17241fb1ad074487a8e867727
--> 76e6d4f2beac
Successfully tagged registry.org/lists/lists:test
76e6d4f2beace6f341d344243be60d64c273bfdaf66860b82eb3f6fa00ced83c

real    0m1.775s
user    0m0.376s
sys     0m0.280s

with --layers

$ podman images --format "{{.Repository}}:{{.Tag}}" | grep 'registry.org/lists/builder' | xargs -r podman rmi
$ podman system prune -f
$ time podman build -f docker/lists/ci/Dockerfile -t registry.org/lists/lists:test --cache-from registry.org/lists/builder --cache-to registry.org/lists/builder --layers .
STEP 1/4: FROM registry.org/lists/lists:acc
STEP 2/4: ADD requirements.dev.txt /tmp
--> Cache pulled from remote registry.org/lists/builder:95a4650b539ccea9d93d38c7d1ee6a7e80fa52e3d975097fe7e8af6b1db6053c:95a4650b539ccea9d93d38c7d1ee6a7e80fa52e3d975097fe7e8af6b1db6053c
--> Using cache 5a0e4396325023047038d3d49e7a68a03d35d33bb989136307b63bc148c4b965
--> 5a0e43963250
STEP 3/4: RUN --mount=type=cache,target=/root/.cache     apk add --no-cache --virtual devreqs gcc python3-dev musl-dev linux-headers &&     pip3 install -t /app/python_modules_test -r /tmp/requirements.dev.txt --no-compile &&     apk del devreqs
--> Cache pulled from remote registry.org/lists/builder:72229fe5ee2420647a548eb64a9cca511875b4c9f793fb990adbe7facaa1627f:72229fe5ee2420647a548eb64a9cca511875b4c9f793fb990adbe7facaa1627f
--> Using cache 265709f9d4506055aa03577e6bc0791ba2be165871259f39bb549ef3c1a5d6f2
--> 265709f9d450
STEP 4/4: ENV PYTHONPATH="${PYTHONPATH}:/app/python_modules_test" PATH="${PATH}:/app/python_modules_test/bin"
--> Using cache 76e6d4f2beace6f341d344243be60d64c273bfdaf66860b82eb3f6fa00ced83c
COMMIT registry.org/lists/lists:test
--> Pushing cache [registry.org/lists/builder]:894d3a64c54930b8cf90f268c16bf42684c57be17241fb1ad074487a8e867727
--> 76e6d4f2beac
Successfully tagged registry.org/lists/lists:test
76e6d4f2beace6f341d344243be60d64c273bfdaf66860b82eb3f6fa00ced83c

real    0m1.828s
user    0m0.395s
sys     0m0.231s

if cache is not used (so no --cache-from, --cache-to, or --layers flags are set), the build takes 1 minute.

Is this a documentation error?

Steps to reproduce the issue

There is no issue, is a documentation question.

Describe the results you received

There is no issue, is a documentation question.

Describe the results you expected

There is no issue, is a documentation question.

podman info output

host:
  arch: amd64
  buildahVersion: 1.38.0
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-1:2.1.12-1
    path: /usr/bin/conmon
    version: 'conmon version 2.1.12, commit: e8896631295ccb0bfdda4284f1751be19b483264'
  cpuUtilization:
    idlePercent: 96.01
    systemPercent: 1.71
    userPercent: 2.27
  cpus: 16
  databaseBackend: sqlite
  distribution:
    distribution: arch
    version: unknown
  eventLogger: journald
  freeLocks: 1951
  hostname: altair
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 6.12.6-arch1-1
  linkmode: dynamic
  logDriver: journald
  memFree: 6756691968
  memTotal: 15907188736
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.13.1-1
      path: /usr/lib/podman/aardvark-dns
      version: aardvark-dns 1.13.1
    package: netavark-1.13.1-1
    path: /usr/lib/podman/netavark
    version: netavark 1.13.1
  ociRuntime:
    name: crun
    package: crun-1.19.1-2
    path: /usr/bin/crun
    version: |-
      crun version 1.19.1
      commit: 3e32a70c93f5aa5fea69b50256cca7fd4aa23c80
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-2024_11_27.c0fbc7e-1
    version: |
      pasta 2024_11_27.c0fbc7e
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  rootlessNetworkCmd: pasta
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /etc/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 0
  swapTotal: 0
  uptime: 182h 4m 58.00s (Approximately 7.58 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  docker.io:
    Blocked: false
    Insecure: false
    Location: docker.io
    MirrorByDigestOnly: false
    Mirrors:
    - Insecure: false
      Location: registry.org
      PullFromMirror: ""
    Prefix: docker.io
    PullFromMirror: ""
  search:
  - docker.io
store:
  configFile: /home/user/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/user/.local/share/containers/storage
  graphRootAllocated: 500856545280
  graphRootUsed: 287223005184
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "true"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 91
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/user/.local/share/containers/storage/volumes
version:
  APIVersion: 5.3.1
  Built: 1732225906
  BuiltTime: Thu Nov 21 22:51:46 2024
  GitCommit: 4cbdfde5d862dcdbe450c0f1d76ad75360f67a3c
  GoVersion: go1.23.3
  Os: linux
  OsArch: linux/amd64
  Version: 5.3.1

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

Additional environment details

Additional information

Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

1 participant