账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    dockerfile中的RUN pwd似乎不起作用
    49
    0
    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 IOSand the full content of my docker file can be seen as below:FROM ubuntu:latestMAINTAINER xxxRUN mkdir -p /ln && echo hello world > /ln/wd6.txtWORKDIR /lnRUpwdCMD ["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 worldlnhowever, 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 本机存在的一个路径+新文件夹的名字这个命令,其实我理应并不会在本机存在的这个路径下面看到这个被创建的新的文件夹,对吗
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 找芣菿嬡哋亾 普通会员 1楼

      RUN pwd 是一个用于运行系统命令(通常是 cd)的指令。然而,它在 Dockerfile 中并不是必需的。在 Dockerfile 中,你可以使用 WORKDIR 或者 DIR 指令来指定工作目录。

      如果你想在 Dockerfile 中使用 RUN pwd,你可以这样做:

      ```dockerfile

      这里是你的 Dockerfile

      RUN pwd ```

      如果你想在 WORKDIR 或者 DIR 指令中使用 RUN pwd,你需要在你的 Dockerfile 中添加以下内容:

      ```dockerfile

      这里是你的 Dockerfile

      WORKDIR /my-workspace RUN pwd ```

      在这个例子中,/my-workspace 是你的工作目录,RUN pwd 会自动将其设置为当前工作目录。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部