在Docker中更改目录命令? [英] Change directory command in Docker?
问题描述
在docker中,我想这样做:
In docker I want to do this:
git clone XYZ
cd XYZ
make XYZ
但是由于没有cd命令,我每次都必须通过完整路径(使XYZ /完整路径)。有任何好的解决方案吗?
However because there is no cd command, I have to pass in the full path everytime (make XYZ /fullpath). Any good solutions for this?
推荐答案
您可以运行脚本,或者运行RUN的参数更复杂。这是我先前下载以查看的Dockerfile的示例:
You can run a script, or a more complex parameter to the RUN. Here is an example from a Dockerfile I've downloaded to look at previously:
RUN cd /opt && unzip treeio.zip && mv treeio-master treeio && \
rm -f treeio.zip && cd treeio && pip install -r requirements.pip
由于使用'&&',它将
Because of the use of '&&', it will only get to the final 'pip install' command if all the previous commands have succeeded.
事实上,由于每个RUN都会创建一个新的commit& (当前)AUFS层,如果Dockerfile中的命令过多,则会用尽限制,因此合并RUN(文件稳定时)可能是非常有用的事情。
In fact, since every RUN creates a new commit & (currently) an AUFS layer, if you have too many commands in the Dockerfile, you will use up the limits, so merging the RUNs (when the file is stable) can be a very useful thing to do.
这篇关于在Docker中更改目录命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!