Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: Download all from nltk in Dockerfile

How would I achieve the following in a Dockerfile:

sudo python
import nltk
nltk.download('all')
like image 830
Robben_Ford_Fan_boy Avatar asked Apr 03 '17 10:04

Robben_Ford_Fan_boy


2 Answers

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
like image 184
m0nhawk Avatar answered Sep 26 '22 17:09

m0nhawk


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!

like image 44
rmeertens Avatar answered Sep 25 '22 17:09

rmeertens