#TIL #linux CR LF를 LF로 바꿔야 할 때는 dos2unix

standard_init_linux.go:175: exec user process caused "no such file or directory"

docker for windows에서 본 에러 메시지. 뭐가 문제인 거지?

root@bbfb0023c2df:/usr/local/bin# ./entrypoint.sh
bash: ./entrypoint.sh: /bin/bash^M: bad interpreter: No such file or directory

조물딱 거리다 보니 다른 에러 메시지가 나왔다. 아~ 라인엔딩 때문이다. windows 환경에서 작성한 entrypoint.sh 파일을 docker 컨테이너에서 실행한다. LF만 쓰는 리눅스에서 CR LF를 사용한 파일을 실행하다 문제가 생긴 거.

RUN apt-get update && apt-get install -y dos2unix
COPY entrypoint.sh /entrypoint.sh
RUN dos2unix /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

복사 후 dos2unix 프로그램으로 라인엔딩을 바꿔주면 된다.

참고 - Docker for Windows: Dealing With Windows Line Endings - willi.am/blog

Feedback plz <3 @ohyecloudy, ohyecloudy@gmail.com

A Random Post