Docker를 사용해서 Jenkins를 띄우려고 하는데, 다른 개발자 분의 개발 환경에서는 Dockerfile이 정상적으로 build 되는 반면, 내 로컬에서는 에러가 났다.
에러 내용
=> ERROR [2/5] RUN <<EOF (apt-get update...) 9.4s
------
> [2/5] RUN <<EOF (apt-get update...):
#9 8.358 E: Invalid operation update
#9 8.391 Reading package lists...
#9 8.436 Building dependency tree...
#9 8.437 Reading state information...
#9 8.462 E: Unable to locate package sudo
#9 8.464 /bin/sh: 3: sudo: not found
.ZIP.or awscliv2.zipnot find or open awscliv2.zip
#9 8.480 /bin/sh: 5: sudo: not found
------
executor failed running [/bin/sh -c apt-get update
apt-get -y install sudo
sudo curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo aws/install
]: exit code: 127
apt-get update 줄부터 command를 찾지 못하고 있음을 발견
원인
RUN <<EOF
apt-get update
apt-get -y install sudo
sudo curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo aws/install
EOF
Dockerfile을 작성한 개발자 분은 macOS에서 작업하는 반면, 나는 Windows 운영체제를 사용한다.
도커 파일에서는 Heredoc의 EOF를 구분 식별자로 사용하였는데, 운영체제의 차이로 인해 실제 실행되는 명령어가 다른 것으로 보인다. (ex.apt-get update\r\n)
해결 방법
RUN apt-get update \
&& apt-get -y install sudo \
&& sudo curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& sudo aws/install
가독성은 다소 떨어지지만, 위와 같이 개행 처리를 함으로써 Dockerfile을 통해 성공적으로 이미지를 생성 할 수 있었다.
'Troubleshooting' 카테고리의 다른 글
[JPA] Failed to create query for method public abstract. No property found for type. (0) | 2023.07.27 |
---|---|
[Spring Security] HandlerMappingIntrospector is required to use MvcRequestMatcher (0) | 2023.06.15 |