我是 Docker 的初学者。我写了一个小Dockerfile
开始。我无法使用以下 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
.我也试过跟随,但它没有克隆 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 <umair@myworkout.no>
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 <umair@myworkout.no>
Date: Tue Jan 9 12:51:57 2018 +0100
root@1377e0a4735d:/LocalizableGenerator#
我不认为你想要
VOLUME
指令虽然。 VOLUME
用于将目录从容器外部挂载到容器本身。在这里,您已经拥有容器中的目录。
关于git - 如何使用 Dockerfile 克隆 git repo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48357742/