{"id":265,"date":"2024-12-09T20:34:35","date_gmt":"2024-12-09T12:34:35","guid":{"rendered":"https:\/\/blog.faspand.top\/?p=265"},"modified":"2024-12-09T20:34:35","modified_gmt":"2024-12-09T12:34:35","slug":"docker%e8%b7%a8%e5%b9%b3%e5%8f%b0%e5%af%bc%e5%87%ba-%e5%af%bc%e5%85%a5%e9%95%9c%e5%83%8f%e6%97%b6%e6%8a%a5%e9%94%99%ef%bc%9aarchive-tar-invalid-tar-header","status":"publish","type":"post","link":"https:\/\/blog.faspand.top\/index.php\/2024\/12\/09\/docker%e8%b7%a8%e5%b9%b3%e5%8f%b0%e5%af%bc%e5%87%ba-%e5%af%bc%e5%85%a5%e9%95%9c%e5%83%8f%e6%97%b6%e6%8a%a5%e9%94%99%ef%bc%9aarchive-tar-invalid-tar-header\/","title":{"rendered":"Docker\u8de8\u5e73\u53f0\u5bfc\u51fa\/\u5bfc\u5165\u955c\u50cf\u65f6\u62a5\u9519\uff1a&#8221;archive\/tar: invalid tar header&#8221;"},"content":{"rendered":"<p>\u4eca\u5929\u5728\u628awindows\u4e0a\u4f7f\u7528 <code>docker save [image] &gt; file.tar<\/code> \u5bfc\u51fa\u7684\u955c\u50cf\u5bfc\u5165\u81f3Linux\u5e73\u53f0\u65f6\u62a5\u9519 <code>archive\/tar: invalid tar header<\/code>\u3002\u5728 Stack Overflow\u68c0\u7d22\u540e\u53d1\u73b0\u662fpowershell\u7684\u95ee\u9898\uff1a<\/p>\n<blockquote><p>\n  I&#8217;ve found it&#8217;s not a windows specific issue. It&#8217;s a powershell issue. Powershell emits two byte characters to STDOUT, not one byte characters. If you look in the file you&#8217;ll notice that the TAR header has nulls between what should be the correct header (and in the rest of the file). This explains why the file is twice the size.<br \/>\n  CMD on the other hand does not emit multibyte characters to STDOUT. I&#8217;ve found the STDOUT method of saving a file works fine across different OSes if you use CMD on windows.<br \/>\n  \u2014\u2014@GiskardReventlov<br \/>\n  \u6211\u53d1\u73b0\u8fd9\u4e0d\u662f Windows \u7279\u6709\u7684\u95ee\u9898\u3002\u8fd9\u662f\u4e00\u4e2a Powershell \u95ee\u9898\u3002Powershell \u4f1a\u5411 STDOUT \u53d1\u9001\u4e24\u4e2a\u5b57\u8282\u7684\u5b57\u7b26\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u5b57\u8282\u7684\u5b57\u7b26\u3002\u5982\u679c\u4f60\u67e5\u770b\u6587\u4ef6\uff0c\u5c31\u4f1a\u53d1\u73b0 TAR \u5934\u672c\u5e94\u662f\u6b63\u786e\u7684\u5934\u4e4b\u95f4\uff08\u4ee5\u53ca\u6587\u4ef6\u7684\u5176\u4ed6\u90e8\u5206\uff09\u6709\u7a7a\u683c\u3002\u8fd9\u5c31\u89e3\u91ca\u4e86\u4e3a\u4ec0\u4e48\u6587\u4ef6\u7684\u5927\u5c0f\u662f\u539f\u6765\u7684\u4e24\u500d\u3002<br \/>\n  \u53e6\u4e00\u65b9\u9762\uff0cCMD \u4e0d\u4f1a\u5411 STDOUT \u53d1\u9001\u591a\u5b57\u8282\u5b57\u7b26\u3002\u6211\u53d1\u73b0\uff0c\u5982\u679c\u5728 Windows \u4e0b\u4f7f\u7528 CMD\uff0cSTDOUT \u4fdd\u5b58\u6587\u4ef6\u7684\u65b9\u6cd5\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u90fd\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002\n<\/p><\/blockquote>\n<p>\u56e0\u6b64\uff0c\u5728Windows\u6253\u5305Docker\u955c\u50cf\u65f6\uff0c\u6700\u597d\u4f7f\u7528<code>docker save [image] -o file.tar<\/code>\u548c<code>docker load -i file.tar<\/code>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u5728\u628awindows\u4e0a\u4f7f\u7528 docker save [image] &gt; file.tar \u5bfc\u51fa\u7684\u955c\u50cf\u5bfc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":266,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-265","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-experience"],"_links":{"self":[{"href":"https:\/\/blog.faspand.top\/index.php\/wp-json\/wp\/v2\/posts\/265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.faspand.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.faspand.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.faspand.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.faspand.top\/index.php\/wp-json\/wp\/v2\/comments?post=265"}],"version-history":[{"count":0,"href":"https:\/\/blog.faspand.top\/index.php\/wp-json\/wp\/v2\/posts\/265\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.faspand.top\/index.php\/wp-json\/wp\/v2\/media\/266"}],"wp:attachment":[{"href":"https:\/\/blog.faspand.top\/index.php\/wp-json\/wp\/v2\/media?parent=265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.faspand.top\/index.php\/wp-json\/wp\/v2\/categories?post=265"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.faspand.top\/index.php\/wp-json\/wp\/v2\/tags?post=265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}