quarkusio/quarkus · error · UnsupportedOperationException

Unable to save enhanced Dockerfile contents to disk

Error message

Unable to save enhanced Dockerfile contents to disk

What it means

During AOT-optimized container image building, Quarkus generates a Dockerfile.aot that wraps the base image with AOT cache instructions. It writes this file into the build output directory with Files.write; if the filesystem write fails (IOException), the build is aborted with this UnsupportedOperationException wrapping the cause.

Source

Thrown at extensions/container-image/container-image-docker/deployment/src/main/java/io/quarkus/container/image/docker/deployment/DockerProcessor.java:257

        Path outputDirectory = outputTargetBuildItem.getOutputDirectory();

        Path aotFile = requestBuildItem.getAotFile();
        String aotEnhancedDockerfileContent = """
                FROM %s

                # Add the app.aot file to the working directory
                COPY %s %s

                # Set the JAVA_TOOL_OPTIONS environment variable
                ENV JAVA_TOOL_OPTIONS="-XX:AOTCache=%s"
                """.formatted(baseImage, outputDirectory.relativize(aotFile).toString().replace('\\', '/'),
                requestBuildItem.getContainerWorkingDirectory(), aotFile.getFileName());

        Path aotEnhancedDockerfile = outputDirectory.resolve("Dockerfile.aot");
        try {
            Files.write(aotEnhancedDockerfile, aotEnhancedDockerfileContent.getBytes());
        } catch (IOException e) {
            throw new UnsupportedOperationException("Unable to save enhanced Dockerfile contents to disk", e);
        }

        boolean pushContainerImage = containerImageConfig.isPushExplicitlyEnabled();

        String executableName = getExecutableName(dockerConfig, ContainerRuntime.DOCKER, ContainerRuntime.PODMAN);
        var dockerBuildArgs = getDockerBuildArgs(enhancedImage, new DockerfilePaths() {
            @Override
            public Path dockerfilePath() {
                return aotEnhancedDockerfile;
            }

            @Override
            public Path dockerExecutionPath() {
                return outputDirectory;
            }
        }, containerImageConfig,
                dockerConfig, pushContainerImage, executableName, Collections.emptyList());

View on GitHub (pinned to e1c734241f)

Solutions

  1. Check free disk space on the volume holding target/ (or the configured output directory)
  2. Verify the output directory is writable by the user running the Maven/Gradle build (chown/chmod as needed)
  3. Remove the stale or read-only target/ directory and rebuild
  4. Check the wrapped IOException in the stack trace for the exact OS reason (e.g. 'No space left on device', 'Read-only file system')

Example fix

# before: read-only mount
-v /ro-workspace:/project
# after: writable mount
-v /home/ci/workspace:/project
Defensive patterns

Strategy: validation

Validate before calling

Path out = Paths.get("target");
if (!Files.isDirectory(out) || !Files.isWritable(out)
        || out.toFile().getUsableSpace() < 50 * 1024 * 1024) {
    throw new IllegalStateException("Output dir missing, read-only, or low on disk space");
}

Type guard

boolean canWriteDockerfile(Path dir) {
    return Files.isDirectory(dir) && Files.isWritable(dir);
}

Try / catch

try {
    Files.write(aotEnhancedDockerfile, content.getBytes());
} catch (IOException e) {
    throw new UncheckedIOException("Cannot write Dockerfile.aot to " + aotEnhancedDockerfile, e);
}

Prevention

When it happens

Trigger: Running a container-image build with AOT optimization enabled (quarkus.native.aot... / AOT request build item) while the output directory is not writable, is read-only, has been deleted, is on a full disk, or the path resolves to a directory that cannot be created.

Common situations: Building in a CI container with a read-only workspace, disk quota exhausted, output/target directory cleaned by a concurrent process, or permission-restricted build agents (e.g. non-root user in /workspace owned by root).

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/22ee1576dcac969c. Report an issue: GitHub.