我想從Dockerfile創建一個圖像。無法更改目錄,同時建立碼頭使用碼頭文件圖像
# cat Dockerfile
FROM ubuntu:16.04
COPY $pwd/intel_virtual_gateway_console64_1_9_0.tar /root/
COPY $pwd/login.exp /root/
RUN cd /root
RUN echo $PWD
RUN tar -xvf intel_virtual_gateway_console64_1_9_0.tar
RUN cd virtualgatewayconsole_package
RUN apt-get update && apt-get install expect \
expect-dev
在構建圖像的目錄不獲取改爲/根/。我認爲問題可能是tar文件丟失,以便確認在將其更改爲/ root目錄後打印當前工作目錄。但是,我已在容器中驗證了軟件包已成功複製到/ root目錄。我甚至通過對其他目錄的實驗進行了驗證,即使那些目錄沒有改變。 由於對這一問題的後續步驟失敗:
# docker build -t release:1.0 .
Sending build context to Docker daemon 633.2MB
Step 1/8 : FROM ubuntu:16.04
---> 6a2f32de169d
Step 2/8 : COPY $pwd/intel_virtual_gateway_console64_1_9_0.tar /root/
---> Using cache
---> 36e9ea407082
Step 3/8 : COPY $pwd/login.exp /root/
---> Using cache
---> 578f9f9481d9
Step 4/8 : RUN cd /root
---> Running in 07ccfc507888
---> ad60f9d31c7e
Removing intermediate container 07ccfc507888
Step 5/8 : RUN echo $PWD
---> Running in e0ec2df6a0dc
/
---> 979a42368814
Removing intermediate container e0ec2df6a0dc
Step 6/8 : RUN tar -xvf intel_virtual_gateway_console64_1_9_0.tar
---> Running in 0701db595e27
tar: intel_virtual_gateway_console64_1_9_0.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
The command '/bin/sh -c tar -xvf intel_virtual_gateway_console64_1_9_0.tar' returned a non-zero code: 2
但能夠改變容器內的目錄。
# docker run -it 979a42368814 /bin/bash
[email protected]:/# pwd
/
[email protected]:/# cd /root/
[email protected]:~# pwd
/root
請幫助找出是什麼原因造成的問題。