LogoLogo
HomeBlogGitHubGet Started FreeLogin
Earthly 0.6
Earthly 0.6
  • 👋Introduction
  • 💻Installation
  • 🎓Learn the basics
    • Part 1: A simple Earthfile
    • Part 2: Outputs
    • Part 3: Adding dependencies With Caching
    • Part 4: Args
    • Part 5: Importing
    • Part 6: Using Docker In Earthly
    • Final words
  • ✅Best practices
  • 📖Docs
    • Guides
      • Authenticating Git and image registries
      • Target, artifact and command referencing
      • Build arguments and secrets
      • User-defined commands (UDCs)
      • Managing cache
      • Advanced local caching
      • Using Docker in Earthly
      • Integration Testing
      • Debugging techniques
      • Multi-platform builds
      • Podman
      • Configuring registries
        • AWS ECR
        • GCP Artifact Registry
        • Azure ACR
        • Self-signed certificates
      • Using the Earthly Docker Images
        • earthly/earthly
        • earthly/buildkitd
    • Remote runners
    • Remote caching
    • Earthfile reference
      • Builtin args
      • Excluding patterns
      • Version-specific features
    • The earthly command
    • Configuration reference
    • Examples
    • Misc
      • Alternative installation
      • Data collection
      • Definitions
      • Public key authentication
  • 🔧CI Integration
    • Overview
    • Use the Earthly CI Image
    • Build your own Earthly CI Image
    • Pull-Through Cache
    • Remote BuildKit
    • Vendor-Specific Guides
      • Jenkins
      • Circle CI
      • GitHub Actions
      • AWS CodeBuild
      • Kubernetes
      • Google Cloud Build
      • GitLab CI/CD
      • Woodpecker CI
  • ☁️ Earthly Cloud
    • Overview
    • Cloud secrets
    • Satellites
      • Managing Satellites
      • Using Satellites
Powered by GitBook
On this page
  • Cache layers
  • Cache location
  • Specifying cache size limit
  • Resetting cache
  • See also

Was this helpful?

Edit on GitHub
  1. Docs
  2. Guides

Managing cache

PreviousUser-defined commands (UDCs)NextAdvanced local caching

Last updated 1 year ago

Was this helpful?

Earthly cache works similarly to Dockerfile layer-based caching. In fact, the same is used underneath.

Cache layers

Many Earthfile commands create cache layers. A cache layer may be reused in a future build, if the conditions under which it is created are the same.

Examples of commands which create layers are COPY and RUN.

One of the main things influencing the conditions are "sources". Sources are created through commands like COPY and GIT CLONE. RUN, however, is not a source, even if the command itself involves downloading content from an external location. This means that a RUN command, on its own, would always be cached if it has been run under the same circumstances previously (except for the RUN --push variant).

For a primer into Dockerfile caching see . The same principles apply to Earthfiles.

Cache location

Earthly cache is persisted in a docker volume called earthly-cache on your system. When Earthly starts for the first time, it brings up a BuildKit daemon in a Docker container, which initializes the earthly-cache volume. The volume is managed by Earthly's BuildKit daemon and there is a regular garbage-collection for old cache.

Checking current cache size

You can check the current size of the cache by running:

sudo du -h /var/lib/docker/volumes/earthly-cache | tail -n 1

Specifying cache size limit

The default cache size is adaptable depending on available space on your system. If you would like to limit the cache size more aggressively, you can specify a different limit by modifying the cache_size_mb and/or cache_size_pct settings in the . For example:

global:
  cache_size_mb: 10000
  cache_size_pct: 70

Resetting cache

The cache can be safely deleted manually, if the daemon is not running

docker stop earthly-buildkitd
docker rm earthly-buildkitd
docker volume rm earthly-cache

However, it is easier to simply use the command

earthly prune --reset

which restarts the daemon and resets the contents of the cache volume.

See also

📖
technology
this article
configuration
Advanced local caching techniques
Remote caching