Docker build 시 ERROR: failed to solve: failed to compute cache key: failed to calculate checksum 오류
다음 docker file의 line 11, 12, 15, 16, 19, 20에서 같은 오류가 발생합니다.
FROM ubuntu:22.04@sha256:b6b83d3c331794420340093eb706a6f152d9c1fa51b262d9bf34594887c2c7ac
ENV user fsb_overwrite
ENV chall_port 7182
RUN apt-get update
RUN apt-get -y install socat
RUN adduser $user
ADD ./private/flag /home/$user/flag
ADD ./public/$user /home/$user/$user
RUN chown -R root:root /home/$user
RUN chown root:$user /home/$user/flag
RUN chown root:$user /home/$user/$user
RUN chmod 755 /home/$user
RUN chmod 755 /home/$user/$user
RUN chmod 440 /home/$user/flag
WORKDIR /home/$user
USER $user
EXPOSE $chall_port
CMD socat -T 10 TCP-LISTEN:$chall_port,reuseaddr,fork EXEC:/home/$user/$user
제가 입력한 커맨드와 오류메시지는 다음과 같습니다.
- 현재 디렉터리 > fsb > Dockerfile 인 상태
$> docker build ./fsb -t fsb
[+] Building 1.9s (10/17) docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 648B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:22.04@sha256:b6b83d3c331794420340093eb706a6f152d9c1fa51b262d9bf34594887c2c7ac 1.8s
=> [ 1/13] FROM docker.io/library/ubuntu:22.04@sha256:b6b83d3c331794420340093eb706a6f152d9c1fa51b262d9bf34594887c2c7ac 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 2B 0.0s
=> CACHED [ 2/13] RUN apt-get update 0.0s
=> CACHED [ 3/13] RUN apt-get -y install socat 0.0s
=> CACHED [ 4/13] RUN adduser fsb_overwrite 0.0s
=> ERROR [ 5/13] ADD ./private/flag /home/fsb_overwrite/flag 0.0s
=> ERROR [ 6/13] ADD ./public/fsb_overwrite /home/fsb_overwrite/fsb_overwrite 0.0s
------
> [ 5/13] ADD ./private/flag /home/fsb_overwrite/flag:
------
------
> [ 6/13] ADD ./public/fsb_overwrite /home/fsb_overwrite/fsb_overwrite:
------
Dockerfile:11
--------------------
9 | RUN adduser $user
10 |
11 | >>> ADD ./private/flag /home/$user/flag
12 | ADD ./public/$user /home/$user/$user
13 |
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref ebe7b14f-c423-4bb4-8eab-0b0fcd3166d0::ebm145yqsrr74xwiu2grw5dtg: failed to walk /var/snap/docker/common/var-lib-docker/tmp/buildkit-mount3959528649/private: lstat /var/snap/docker/common/var-lib-docker/tmp/buildkit-mount3959528649/private: no such file or directory
#pwnable
작성자 정보
답변
1
cityofwonder
대표 업적 없음
엄 제가 작성하고 제가 답변하네요
워게임 파일을 받으면 ./private/flag 경로에 flag 파일이 있어서 이걸 참조하여 docker 환경 내에 copy하는 방식이었던 것 같습니다
근데 참조할게 없어서 나는 오류였기에, 기존 line 11, 12의 ./private, ./public 부분을 수정하고, 워게임 디렉터리 아래에 flag 파일을 임의로 생성했습니다.
아래는 수정 버전입니다.
FROM ubuntu:22.04@sha256:b6b83d3c331794420340093eb706a6f152d9c1fa51b262d9bf34594887c2c7ac
ENV user fsb_overwrite
ENV chall_port 7182
RUN apt-get update
RUN apt-get -y install socat
RUN adduser $user
WORKDIR /home/$user
ADD flag /home/$user/flag
ADD $user /home/$user/$user
RUN chown -R root:root /home/$user
RUN chown root:$user /home/$user/flag
RUN chown root:$user /home/$user/$user
RUN chmod 755 /home/$user
RUN chmod 755 /home/$user/$user
RUN chmod 440 /home/$user/flag
USER $user
EXPOSE $chall_port
CMD socat -T 10 TCP-LISTEN:$chall_port,reuseaddr,fork EXEC:/home/$user/$user