Docker:更改目录命令 [英] Docker: change directory command

查看:131
本文介绍了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。以下是我先前下载的Docker文件的一个例子:

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

由于使用'&&',它将如果所有以前的命令都成功,只能进入最终的pip install命令。

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屋!

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