Docker: Download all from nltk in Dockerfile

How would I achieve the following in a Dockerfile:

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

  • Moving MongoDB dbpath to an AWS EBS device
  • Docker save/load loose original image repository/name/tag
  • Is it possible to combine and push multicontainer/images docker app to docker-hub? if yes how?
  • How to run docker image as singleton
  • Cannot shutdown high load docker mysql
  • How docker treats fsync on guest filesystem? Is it possible to lost data during host system crash?
  • Docker remove all images permission denied
  • Kafka producer configuration and docker
  • Copy Postgres database structures but not data
  • How do I reload haproxy.cfg on the default Dockerfile?
  • Docker scaling containers on a single host
  • How to connect to service in the host machine from inside a docker container?
  • 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.