在docker build期间将密码参数传递或设置为mercurial

时间:2016-03-14 04:22:31

标签: ubuntu docker mercurial

我正在尝试设置泊坞窗图片,而我的代码库位于bitbucket中。这里的问题是mercurial要求密码来克隆存储库。经过一番研究后发现,在docker build过程中,它并不允许用户输入任何内容。该命令在hg clone请求授权后立即停止。任何解决方法?感谢

示例dockerfile。

FROM ubuntu
RUN apt-get update
RUN apt-get install -y nodejs npm git git-core
RUN apt-get -y install mercurial
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN npm install -g bower
RUN npm install -g grunt-cli
RUN hg clone <repository>

1 个答案:

答案 0 :(得分:0)

您需要配置凭据(ssh密钥)或通过Mercurial命令行传递它。

http://mercurial.aragost.com/kick-start/en/remote/#caching-of-http-s-credentials

如果您不希望将ssh密钥保存在Docker镜像中,则可以在容器中手动执行这些步骤(使用克隆 http://user:password@host/repo)。 然后将容器提交到图像。

host$ docker run -it --name clonedRepoContainer ubuntu bash 
container$ apt-get update
container$ apt-get install -y nodejs npm git git-core
container$ apt-get -y install mercurial
container$ ln -s /usr/bin/nodejs /usr/bin/node
container$ npm install -g bower
container$ npm install -g grunt-cli
container$ hg clone http://user:password@host/repo
host$ docker commit clonedRepoContainer finalImage