I am studying on Docker these days and confused that why RUN pwd just does not seem to work while running my docker file.
I am working on IOS
and the full content of my docker file can be seen as below:
FROM ubuntu:latest
MAINTAINER xxx
RUN mkdir -p /ln && echo hello world > /ln/wd6.txt
WORKDIR /ln
RUpwd
CMD ["more" ,"wd6.txt"]
as far as my understanding, after building the docker image with the tag 'wd8'and running it, I supposed the result should show like this
~ % docker run wd8
::::::::::::::
wd6.txt
::::::::::::::
hello world
ln
however, the fact is without ln
.
I have tried with RUN $pwd, and also added ENV at the beginning of my dockerfile, both do not work.
Please help point out where the problem is.
上面的内容是因为先在stackoverflow发帖问的,所以直接把问题内容粘贴过来了。。
顺便想问一下所以是不是RUN mkdir 本机存在的一个路径+新文件夹的名字
这个命令,其实我理应并不会在本机存在的这个路径下面看到这个被创建的新的文件夹,对吗
你需要理解,“构建时” 和 “运行时” 的区别,Dockerfile 中的命令只是会在构建时,即运行
docker build
命令时运行。而最终构建完成后使用
docker run
运行镜像时,只会去执行CMD
或者Entrypoint
指定的命令。