Docker: Download all from nltk in Dockerfile

How would I achieve the following in a Dockerfile:

sudo python
import nltk
nltk.download('all')

  • Cannot start simple docker container with “docker start” command from created image
  • django postgresql password authentication failed for user
  • How to start Docker for Mac daemon on boot?
  • Docker build times long with npm global install angular-cli
  • Jupyterhub with dockerspawner does not run - error 502
  • Can not add a volume to Mongodb Docker instance
  • Reverse engineering a Docker deployment on private cloud
  • Jenkins docker setup
  • How to start Docker for Mac daemon on boot?
  • Hosting Wordpress with docker on Azure
  • how process static file when deploying django using docker and aws eb
  • I can't run rails console with Docker and Passenger/nginx image
  • 2 Solutions collect form web for “Docker: Download all from nltk in Dockerfile”

    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
    

    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!

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.