<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dockerfile 彙整 - 泰克哪裡去</title>
	<atom:link href="https://tech.uccu.website/tag/dockerfile/feed" rel="self" type="application/rss+xml" />
	<link>https://tech.uccu.website/tag/dockerfile</link>
	<description>一個科技相關的隨手記錄網站</description>
	<lastBuildDate>Sat, 28 Aug 2021 15:37:02 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
<site xmlns="com-wordpress:feed-additions:1">119574712</site>	<item>
		<title>解決.sh檔案在Container內執行時的換行字元(CRLF/LF)問題</title>
		<link>https://tech.uccu.website/convert-shell-file-end-of-line-sequence-at-dockerfile.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=convert-shell-file-end-of-line-sequence-at-dockerfile</link>
					<comments>https://tech.uccu.website/convert-shell-file-end-of-line-sequence-at-dockerfile.html#respond</comments>
		
		<dc:creator><![CDATA[鳴人]]></dc:creator>
		<pubDate>Tue, 24 Nov 2020 09:47:26 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[crlf]]></category>
		<category><![CDATA[dockerfile]]></category>
		<category><![CDATA[dos2unix]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<guid isPermaLink="false">https://tech.uccu.website/?p=158</guid>

					<description><![CDATA[<p>如果有在使用Docker並且是建置Linux環境的Image，搭配自行撰寫的shell檔案，有時候會因為版本控 ... <a title="解決.sh檔案在Container內執行時的換行字元(CRLF/LF)問題" class="read-more" href="https://tech.uccu.website/convert-shell-file-end-of-line-sequence-at-dockerfile.html" aria-label="Read more about 解決.sh檔案在Container內執行時的換行字元(CRLF/LF)問題">閱讀全文</a></p>
<p>這篇文章 <a href="https://tech.uccu.website/convert-shell-file-end-of-line-sequence-at-dockerfile.html">解決.sh檔案在Container內執行時的換行字元(CRLF/LF)問題</a> 最早出現於 <a href="https://tech.uccu.website">泰克哪裡去</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>如果有在使用Docker並且是建置Linux環境的Image，搭配自行撰寫的shell檔案，有時候會因為版本控管、編輯器(IDE)等雜七雜八的因素，導致在Dockerfile中複製到Image的時候看起來雖然沒問題，但是在Run Container的時候出現因為換行字元(CRLF/LF)導致的錯誤時，除了可以回頭去調整或修改shell檔案，將換行字元從CRLF轉換成LF之外，還有一個更方便的方法，那就是在shell檔案複製到Docker Image的時候再執行轉換的動作。</p>



<p>起先我在寫Shell檔案的時候真的是碰到了許多次因為CRLF / LF換行字元的問題，早期都是回頭去修改原始檔案之後再重新Build Image，久了之後實在是覺得很麻煩，某天忽然想到直接在Dockerfile中安裝<em><strong>dos2unix</strong></em>這個套件，在shell檔案複製之後再執行它來將shell檔案的換行字元的問題解決，從此之後就沒有再為了Windows / Unix-like不同環境的換行字元問題而煩惱過了，因此特別用這篇文章簡短記錄一下，也許有人也為了這個問題困擇了一段時間呢！</p>



<h2 class="wp-block-heading">Dockerfile內容參考範例</h2>



<pre class="wp-block-prismatic-blocks"><code class="language-docker">RUN apt-get install dos2unix;
COPY my-init.sh .
RUN dos2unix my-init.sh
CMD [&quot;bash&quot;, &quot;my-init.sh&quot;]</code></pre>
<p>這篇文章 <a href="https://tech.uccu.website/convert-shell-file-end-of-line-sequence-at-dockerfile.html">解決.sh檔案在Container內執行時的換行字元(CRLF/LF)問題</a> 最早出現於 <a href="https://tech.uccu.website">泰克哪裡去</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://tech.uccu.website/convert-shell-file-end-of-line-sequence-at-dockerfile.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">158</post-id>	</item>
	</channel>
</rss>
