+-
Docker git clone在容器启动时?
我目前的理解是Docker在docker构建期间执行任何RUN git clone命令,因此我的应用程序的代码库被“烘焙”到Docker镜像中.

当容器启动时,我将如何运行git clone?

或者这被认为是不好的做法和反模式?

我的想法是,每次我对git repo进行任何更改时,我都不想上升我的Docker镜像版本.

最佳答案
常见的设计模式是在Docker镜像构建过程中克隆和编译项目.此外,您可以将映像配置为 Docker Automated Build,在Docker文档中将其定义为:

Automated Builds are a special feature of Docker Hub which allow you
to use Docker Hub’s build clusters to automatically create images from
a specified Dockerfile and a GitHub or Bitbucket repo (or “context”).
The system will clone your repository and build the image described by
the Dockerfile using the repository as the context. The resulting
automated image will then be uploaded to the Docker Hub registry and
marked as an Automated Build.

每当您在指向的仓库的分支中执行提交(和推送)时,自动构建就会启动.如果它经常被触发,也许你应该指向其他分支.

无论如何,如果你选择在运行新容器时运行git clone,你可以使用CMD [“my-script”]配置你的Dockerfile,使用你想要的代码作为my-script任何bash脚本.

点击查看更多相关文章

转载注明原文:Docker git clone在容器启动时? - 乐贴网