如何创build在Ubuntu容器中安装Python 3和nltk的Dockerfile?

我正在尝试使用python 3和nltk tokenizer创build一个Docker容器。 任何人都可以帮助我创buildDockerfile。

这是一个Dockerfile ,它通过python3-nltk debian软件包安装nltk (并且certificate它确实python3-nltk

 FROM ubuntu:xenial RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ python3-nltk && \ rm -rf /var/lib/apt/lists/* CMD ["python3", "-c", "import nltk"] 

请注意, dockerfile最佳实践中build议使用apt-get样板

你可以像这样开始你的Dockerfile:

 FROM python:3-wheezy RUN apt-get update && apt-get install -y git ca-certificates RUN pip install -q nltk #optionally your other docker commands here 

然后build立并运行容器。

Obs:这是一个官方的Debian容器(兼容Ubuntu),如果你喜欢一个纯粹的Ubuntu容器replace“python:3-wheezy”与“dominga / uwsgi-python3”,这是从ubuntu14