A container image needs to automatically extract a local tar archive file named 'app.tar.gz' into the destination directory '/opt/app' during the build process. Which instruction should be used?
Trap 1: COPY app.tar.gz /opt/app/
COPY will simply copy the tar file as a tar file without extracting it.
Trap 2: EXTRACT app.tar.gz /opt/app/
EXTRACT is not a valid Containerfile instruction.
Trap 3: RUN tar -xzf app.tar.gz -C /opt/app/
While this works, it adds an unnecessary extra layer and requires cleaning up the tar file.
- A
COPY app.tar.gz /opt/app/
Why it fails: COPY will simply copy the tar file as a tar file without extracting it.
- B
EXTRACT app.tar.gz /opt/app/
Why it fails: EXTRACT is not a valid Containerfile instruction.
- C
ADD app.tar.gz /opt/app/
ADD automatically recognizes local tar files and extracts them into the destination.
- D
RUN tar -xzf app.tar.gz -C /opt/app/
Why it fails: While this works, it adds an unnecessary extra layer and requires cleaning up the tar file.