Reputation:
How to install packages to docker's python?
For example, I need lmxl
. Inside django application in docker I run pip install lxml
and terminal responses that requirement is already satisfied (because it's installed in OS X python 2.7 packages), but in fact it's not installed in docker's python packages.
So, how to apply pip install something
to docker?
Upvotes: 3
Views: 5031
Reputation: 26372
The correct way is to update the requirements.txt file of your project.
# requirements.txt
# .. other requirements
lxml
add the lxml dependencies to your Dockerfile after (RUN apt-get update .....)
RUN apt-get install -y python-dev libxml2-dev libxslt1-dev zlib1g-dev
now build and run. Using either
docker-compose build
docker-compose up
or
docker-compose up --build
Upvotes: 1
Reputation: 86
There are many ways to install packages in docker but i prefer is to use docker file https://rominirani.com/docker-tutorial-series-writing-a-dockerfile-ce5746617cd#.q00am7bh3
check out these links it might help you.
Upvotes: -1
Reputation: 1500
You would use Docker's docker-compose run --rm --service-ports web bash
command. That will bring you to the command line of the container. Once there, you can run pip install lxml
. After installation, just type exit
, and you will exit the container used to the web
container and remove it.
Here's the article on Docker run for reference: https://docs.docker.com/compose/reference/run/
Upvotes: 1