2014-12-24 205 views
1

这里是泊坞窗的git命令泊坞窗混帐克隆不克隆(而不是示数)

WORKDIR /var/www 
    RUN git clone --verbose [email protected]:<private git repo>.git /var/www 

的混帐克隆命令执行没有错误,但附着在容器后,我找不到项目任何文件夹。我已经尝试在克隆之前将光盘放入/ var/www中,但结果相同。奇怪的是,我预计--verbose标志会输出项目的摘要细节,但它不会。因此,我增加验证ssh连接声明:

RUN \ 
    chmod 600 /repo-key && \ 
    echo "IdentityFile /repo-key" >> /etc/ssh/ssh_config && \ 
    echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \ 
    ssh -v [email protected] 

连接成功,输出:

Hi willlopez! You've successfully authenticated, but GitHub does not provide shell access. 
    debug1: channel 0: free: client-session, nchannels 1 
    debug1: fd 0 clearing O_NONBLOCK 
    debug1: fd 1 clearing O_NONBLOCK 
    debug1: fd 2 clearing O_NONBLOCK 
    Transferred: sent 2944, received 1464 bytes, in 0.1 seconds 
    Bytes per second: sent 31103.1, received 15467.0 
    debug1: Exit status 1 

的混帐克隆输出:

Cloning into '/var/www'... 
    Warning: Permanently added the RSA host key for IP address to the list of known hosts. 

我用nsenter泊坞窗进入附加到正在运行的容器。/var/www为空

+0

是/ var/www声明为一个卷? –

+0

@AdrianMouat是的,它是 –

+0

它需要是一个“工作”目录,以便开发人员可以对项目进行更改,验证更改并将其检入git –

回答

5

我觉得git clone工作正常,但作为/var/www是音量,更改将被丢弃。在Dockerfile中声明音量后,您不能对该direc进行更改保守党;记得在运行时设置卷。

如果您在git clone语句后移动VOLUME语句,它会将文件复制到卷中。如果你不能这样做,你可以在运行时以CMDENTRYPOINT脚本执行克隆。

有关卷的更多信息,请参阅官方文档泊坞窗或https://docs.docker.com/userguide/dockervolumes/这个博客http://container-solutions.com/2014/12/understanding-volumes-docker/

+0

谢谢@AdrianMouat。我从运行命令中删除了卷,现在可以看到git项目。我需要更好地理解卷的工作原理,因为我显然不这样做。不知道它是否因为我使用的是boot2docker而不是“纯粹的”Linux机器盒而变得更加混乱。 –

+0

顺便说一下,dockerfile中的volume命令是git clone命令之后的最后一个命令之一。必须是我的运行命令有问题 –

1

错误是测试的一部分。你正在向GitHub验证。

Hi MakotoTheKnight! You've successfully authenticated, but GitHub does not provide shell access. 
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 
debug1: channel 0: free: client-session, nchannels 1 
Connection to github.com closed. 
Transferred: sent 3632, received 1800 bytes, in 0.1 seconds 
Bytes per second: sent 27200.9, received 13480.6 
debug1: Exit status 1 

这就是说,只要你做git clone,你已经为你的私人混帐回购协议中指定的任何路径,Git会默认使用该目录。它可以通过提供后续参数指定要你的代码放到目录 覆盖(如git clone [email protected]:UserName/someproject.git somedirectory

如果你有写权限到目录,你的代码内容在那里。你可以通过ls -l验证权限,如果你是谁拥有用户或在同一组谁拥有/var/www用户,它应该工作。

+0

谢谢@Makoto我会尽力 –

+0

+ Makoto我尝试过,但仍然没有。我更新了这篇文章。谢谢 –

1

我太一旦误差偶然:

ERROR: Hi [username]! You've successfully authenticated, but GitHub does not provide shell access Connection to github.com closed. 

过去。

在我来说,这是关系到正确设置GIT_SSH环境变量, 也许下面的链接将帮助您太:github: No supported authentication methods available

干杯。

-Ricardo