[英]docker git clone during build is not cloning (and not erroring)
這是 docker git 命令
WORKDIR /var/www
RUN git clone --verbose git@github.com:<private git repo>.git /var/www
git 克隆命令執行無誤,但附加到容器后,我無法在任何文件夾中找到該項目。 我試過在克隆之前 cd 進入 /var/www 但結果相同。 一件奇怪的事,我希望 --verbose 標志為 output 項目的摘要詳細信息,但事實並非如此。 所以我添加了一條語句來驗證ssh連接:
RUN \
chmod 600 /repo-key && \
echo "IdentityFile /repo-key" >> /etc/ssh/ssh_config && \
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
ssh -v git@github.com
連接成功,output:
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
git 克隆 output:
Cloning into '/var/www'...
Warning: Permanently added the RSA host key for IP address to the list of known hosts.
我使用 nsenter docker-enter 附加到正在運行的容器。 /var/www 是空的
我認為git clone
工作正常,但由於/var/www
是一個卷,因此更改被丟棄了。 在Dockerfile
聲明了卷之后,您將無法更改該目錄。 記住在運行時設置卷。
如果將VOLUME
語句移到git clone語句之后,它將把文件復制到卷中。 如果無法執行此操作,則可以在運行時使用CMD
或ENTRYPOINT
腳本執行克隆。
有關卷的更多信息,請參閱正式的Docker文檔https://docs.docker.com/userguide/dockervolumes/或此博客http://container-solutions.com/2014/12/understanding-volumes-docker/
該錯誤是測試的一部分。 您正在通過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默認都會使用該目錄。 可以通過提供一個后續參數指定要放置代碼的目錄來覆蓋它(例如git clone git@github.com:UserName/someproject.git somedirectory
。
如果您具有對該目錄的寫權限,則代碼內容應該在該目錄中。 您可以通過ls -l
驗證權限,如果您是擁有/var/www
的用戶,或者與擁有/var/www
的用戶在同一組,則它應該可以工作。
我也迷失了這個錯誤:
ERROR: Hi [username]! You've successfully authenticated, but GitHub does not provide shell access Connection to github.com closed.
以往。
就我而言,這與正確設置GIT_SSH環境變量有關,也許以下鏈接也可以為您提供幫助: github:沒有可用的受支持的身份驗證方法
干杯。
-里卡多
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.