简体   繁体   中英

How to create Dockerfile which installs Python 3 and nltk in a Ubuntu container?

I am trying to create a Docker container with python 3 and nltk tokenizer. Can anyone help me with creation on of Dockerfile.

Here's a Dockerfile which installs nltk via the python3-nltk debian package (and demonstrates that it indeed works)

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

Note that the apt-get boilerplate is suggested in the dockerfile best practices

You can begin your Dockerfile like this:

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

Then build and run the container.

Obs: This is a official debian based container (compatible with ubuntu) if you like a pure ubuntu container replace "python:3-wheezy" with "dominga/uwsgi-python3" which is built from ubuntu14

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM