为Github项目创建Docker映像 [英] Creating a Docker Image for a Github Project
问题描述
我有一个
这似乎是一个非常基本的问题,但是在 Docker提供的教程,也没有确定的答案 Stackoverflow ,但是这些是无可争议的极好的资源,用于制作终端输出<世界> 的非常复杂的方式。
虽然Sergius的回答没有错,但另外一些方法是通过Dockerfile https://docs.docker.com/reference/builder/ 。这样,您可以在您的github项目中包含一个Docker文件,并将该映像构建在docker集线器上。或者您可以创建一个docker文件,从github提取项目,运行任何必要的构建步骤,然后将其推送到docker hub。
无论如何,您需要构建来自docker文件的图像与
docker build -t< image name> <选项> < build context>
然后您将使用 docker push
对于您项目外的Docker文件:
FROM ubuntu:14.04
RUN apt-get install git&&& \
git clone< your git repo> &安培;&安培; \
<用于构建项目的附加bash命令>
CMD<命令运行您的项目> #也可以在某些情况下使用ENTRYPOINT
I have a GitHub project, (that I am working with (I didn't create it)), called OpenRefine, which I would like to encapsulate in a Docker image, such that other people can then pull that Docker image from the "Docker Hub" and have OpenRefine installed on their fundamental interactive Docker entity, viz. Image.
I want to then upload it to a repository that I can share with others.
It would be good if it had a name and not a crazy hash value.
Is it that I just create a "docker file" a text files with a git clone
command?
but then how to upload that to a repository such as the docker hub? I just put that text file there?
Something like
FROM ubuntu
MAINTAINER :/ WTF?!
RUN git clone blah
CMD what here?
This seems like a very basic issue but the information is not readily accessible in the Docker provided tutorials, nor is there a definitive answer on Stackoverflow, but those are indisputably excellent resources for a very complicated way to make a terminal output "Hello World".
While Sergius' answer isn't wrong, additional ways to do this would be through a Dockerfile https://docs.docker.com/reference/builder/. This way you can either include a Dockerfile in your github project and build that image to put up on docker hub. Or you can create a dockerfile that pulls your project from github, runs any necessary build steps and then push that to docker hub.
In either ways you would need to build the image from the dockerfile with
docker build -t <name of image> <OPTIONS> <build context>
and then you would use docker push
to push the image.
For a Dockerfile outside of your project:
FROM ubuntu:14.04
RUN apt-get install git && \
git clone <your git repo> && \
<additional bash commands for building your project>
CMD <command to run your project> # Can also use ENTRYPOINT in certain cases
这篇关于为Github项目创建Docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!