Creating a Docker Image for a Github Project

◇◆丶佛笑我妖孽 提交于 2019-12-07 09:11:44

问题


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".


回答1:


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



回答2:


I'm not sure, but you can try to fetch some basic docker image, which is suitable to run your application. Build your application there and use "docker commit" to get new image, which will contain that basic image with your application.




回答3:


There are already plenty of Docker images for OpenRefine hosted on the Docker Hub.

Why don't you take example on one of their Dockerfile? This one seems to be the most popular.



来源:https://stackoverflow.com/questions/32189877/creating-a-docker-image-for-a-github-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!