附加到Windows Docker容器中的PATH [英] Appending to PATH in a Windows Docker container

查看:151
本文介绍了附加到Windows Docker容器中的PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Windows Docker容器中附加到PATH,并且我尝试了许多排列.

I need to append to the PATH within a Windows Docker container, and I've tried many permutations.

ENV PATH=%PATH%;C:\\Foo\\bin
ENV PATH=$PATH;C:\\Foo\\bin
ENV PATH="%PATH%;C:\Foo\bin"
ENV PATH="$PATH;C:\Foo\bin"
RUN "set PATH=%PATH%;C:\Foo\bin"

这些工作都不起作用:它们不评估预先存在的PATH变量.

None of these work: they don't evaluate the preexisting PATH variable.

追加到PATH的正确语法是什么?我什至可以在Docker内部添加到PATH吗? (我可以在类似的Linux容器上使用)

What is the right syntax to append to the PATH? Can I even append to the PATH inside Docker? (I can on similar Linux containers)

推荐答案

不幸的是,ENV无法正常工作,因为Windows环境变量的工作方式与linux略有不同. 更多信息

Unfortunately ENV won't work, because windows environment variable work a little differently than linux. more info

到目前为止,唯一的方法是通过RUN

As of now the only way to do this is through RUN

但是您不需要创建单独的文件来执行此操作.这可以通过以下简单得多的一行命令来完成:

But you don't need to create a separate file to do this. This can be done by the following much simpler one line command:

RUN setx path "%path%;C:\Foo\bin"

RUN setx path "%path%;C:\Foo\bin"

这篇关于附加到Windows Docker容器中的PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆