如何为自定义python项目编写Dockerfile? [英] How to write a Dockerfile for a custom python project?

查看:72
本文介绍了如何为自定义python项目编写Dockerfile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Docker的新手,我需要创建一个容器以将Docker容器作为Apache Mesos任务运行.

I'm pretty new to Docker, and I need to create the container to run Docker container as an Apache Mesos task.

问题是我找不到任何相关示例.它们全都围绕Web开发,这不是我的情况.

The problem is that I can't find any relevant examples. They all are centered around Web development, which is not my case.

我有一个具有大量依赖项的纯Python项目(例如Berkeley Caffe或OpenCV).如何编写Docker文件以正确注册所有依赖项(以及如何找出它们)?

I have a pure Python project with large number of dependencies ( like Berkeley Caffe or OpenCV ). How to write a Docker file to properly enroll all dependecies ( and how to find them out?)

推荐答案

docker hub注册表包含许多官方语言图像,您可以将其用作基础图像.

The docker hub registry contains a number of official language images, which you can use as your base image.

说明告诉您如何构建python项目,包括导入依赖项.

The instructions tell you how you can build your python project, including the importation of dependencies.

├── Dockerfile                <-- Docker build file
├── requirements.txt          <-- List of pip dependencies
└── your-daemon-or-script.py  <-- Python script to run

图像同时支持Python 2和Python 3,您可以在Dockerfile中指定它:

Image supports both Python 2 and 3, you specify this in the Dockerfile:

FROM python:3-onbuild
CMD [ "python", "./your-daemon-or-script.py" ]

基本映像使用特殊的 ONBUILD指令来完成所有的工作你.

The base image uses special ONBUILD instructions to all the hard work for you.

这篇关于如何为自定义python项目编写Dockerfile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆