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

crane: cannot push or validate .tar.gz format #1908

Open
a-h opened this issue Mar 27, 2024 · 3 comments
Open

crane: cannot push or validate .tar.gz format #1908

a-h opened this issue Mar 27, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@a-h
Copy link

a-h commented Mar 27, 2024

Describe the bug

crane doesn't support working with .tar.gz files, requiring that Docker container images that are gzipped are first untarred.

Attempting to run crane validate --tarball <filename>.tar.gz results in the error:

Error: failed to read image <filename>.tar.gz: archive/tar: invalid tar header

To Reproduce

  • Create an empty directory.
  • Initialize a git repo in it with git init.
  • Create a flake.nix file containing this content and add it with git add flake.nix:
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/23.11";
  };

  outputs = { self, nixpkgs }:
    let
      allSystems = [
        "x86_64-linux" # 64-bit Intel/AMD Linux
        "aarch64-linux" # 64-bit ARM Linux
      ];
      forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
        system = system;
        pkgs = import nixpkgs {
          inherit system;
        };
      });

      # Build Docker container.
      dockerImageTools = system: pkgs: pkgs.dockerTools.buildImage {
        name = "tools";
        tag = "latest";
        copyToRoot = [
          pkgs.coreutils
          pkgs.bash
          pkgs.jq
        ];
        config = {
          Cmd = [ "bash" ];
        };
      };
    in
    {
      packages = forAllSystems ({ system, pkgs }: {
        docker-image-tools = dockerImageTools system pkgs;
      });
    };
}
  • Run nix build ./#packages.x86_64-linux.docker-image-tools which outputs a result file, which is a .tar.gz file.
  • Run crane validate --tarball /nix/store/8cix3l8fwpz7m5v7cggmk0467s9s7naj-docker-image-tools.tar.gz to see the error.

Expected behavior

Expected it to work without additional steps.

@a-h a-h added the bug Something isn't working label Mar 27, 2024
@a-h
Copy link
Author

a-h commented Mar 27, 2024

This issue would be fixed by merging #1858

I've tested the PR and confirm it works well.

This also probably fixes #1838

@a-h a-h changed the title crane: cannot copy or validate .tar.gz format crane: cannot push or validate .tar.gz format Mar 27, 2024
@zhangguanzhang
Copy link

@jonjohnsonjr PTAL

@zhangguanzhang
Copy link

@imjasonh cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants