Skip to content Skip to sidebar Skip to footer

Docker: Download All From Nltk In Dockerfile

How would I achieve the following in a Dockerfile: sudo python import nltk nltk.download('all')

Solution 1:

You can build a custom Docker image with everything you need:

FROM python:3.6-slim
RUN pip3 install nltk
RUN [ "python", "-c", "import nltk; nltk.download('all')" ]
ENTRYPOINT python

Then build:

docker build -t docker-nltk .

And run:

docker run -it docker-nltk

Solution 2:

If you add your code to the file downloadall.py this Dockerfile does the job on my machine:

FROM python:3
RUN pip install nltk
ADD downloadall.py /
CMD [ "python", "./downloadall.py" ]

Let me know if it works for you!

Solution 3:

This is how to do it properly:

FROM python:3.7

RUN pip install nltk
RUN python -m nltk.downloader all

...rest of Dockerfile...

Post a Comment for "Docker: Download All From Nltk In Dockerfile"