我想从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
请帮助找出是什么原因造成的问题。