如何使用Dockerfile克隆git

如何使用Dockerfile克隆git

本文介绍了如何使用Dockerfile克隆git repo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Docker的初学者.我写了一个小的 Dockerfile 开始.我无法使用以下 Dockerfile 克隆我的存储库.

I am a beginner to Docker. I have written a small Dockerfile to start with. I am not able to clone my repo using following Dockerfile.

FROM mattes/hello-world-nginx
RUN apt-get update && apt-get install -y git
RUN git clone https://github.com/umairnow/LocalizableGenerator.git
VOLUME LocalizableGenerator

我不确定我是否做得正确,还是必须使用 WORKDIR .我还尝试了以下操作,但它没有克隆存储库.

I am not sure if I am doing it right or do I have to use WORKDIR. I have also tried following but it doesn't clone the repo.

VOLUME ["/data"]
WORKDIR /LocalizableGenerator

任何人都可以帮忙吗?

推荐答案

您的 git clone 确实有效:

$ docker build . -t test
...
Successfully built 5370e446d719
Successfully tagged test:latest
$ docker run -ti test /bin/bash
root@1377e0a4735d:/# cd LocalizableGenerator/
root@1377e0a4735d:/LocalizableGenerator# git log | head
commit 289a77330eefb7abaa90ca61e4226a3c29896e58
Author: Umair Aamir <[email protected]>
Date:   Tue Jan 9 13:04:16 2018 +0100

    Improved get input method. Now user can just drag drop file path or paste file path to generate translation files.

commit e3aa870362b24765095eb80d7aa7910964c010f0
Author: Umair Aamir <[email protected]>
Date:   Tue Jan 9 12:51:57 2018 +0100

root@1377e0a4735d:/LocalizableGenerator#

我不认为您需要 VOLUME 指令. VOLUME 用于将目录从容器外部安装到容器本身.在这里,您已经在容器中包含目录.

I don't think you want the VOLUME directive though. VOLUME is used to mount a directory from outside your container to the container itself. Here, you already have the directory within the container.

这篇关于如何使用Dockerfile克隆git repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 20:57