You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker构建镜像时curl下载ZIP包后unzip报invalid zip magic 0A0A0A0A错误

Fixing "unzip: invalid zip magic 0A0A0A0A" When Downloading via curl in Dockerfile

That invalid zip magic 0A0A0A0A error is a dead giveaway—you didn't actually download a valid ZIP file. The 0A is a newline character, which means your java-agent.zip is almost certainly an HTML error page from GitHub (like a 404, permission denied, or redirect response) instead of the actual agent archive.

Here's how to fix this step by step:

  • Add redirect following to your curl command
    GitHub's download links often use 3xx redirects, and default curl behavior doesn't follow them. Add the -L flag to make curl chase redirects, plus -o to ensure the output saves to the correct filename:

    curl -L -o java-agent.zip https://github.com/<your-repo-owner>/<your-repo>/releases/download/<release-tag>/java-agent.zip
    
  • Double-check your GitHub download URL
    Make sure you're using the release asset URL, not the source code ZIP link. Source code links end with /archive/refs/tags/<tag>.zip—if you're after a pre-built agent, grab the link from the "Assets" section of the repo's release page instead.

  • Handle private repo permissions
    If the repo is private, curl will return an HTML login page instead of the ZIP. Add a GitHub personal access token (with repo scope) to your request:

    curl -L -H "Authorization: token YOUR_GITHUB_PAT" -o java-agent.zip https://github.com/<your-repo-owner>/<your-repo>/releases/download/<release-tag>/java-agent.zip
    

    Pro tip: Don't hardcode tokens in your Dockerfile—use build args or secrets for better security.

  • Debug the downloaded file (optional but useful)
    Add a quick step to inspect the file content before unzipping to confirm it's not HTML:

    RUN head java-agent.zip
    

    If you see <html> or <body> tags, you know your URL or permissions still need fixing.

Once you adjust the curl command to pull down a valid ZIP archive, that unzip error should vanish.

内容的提问来源于stack exchange,提问作者Siraj Syed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:41:04