Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check whether python package is installed or not in Docker?

I used Dockerfile successfully built a container. However, my code doesn't work in the container. It does work if I install all the packages manually. I'm assuming I messed up something that cause docker didn't install the packages properly. So, I want to check whether python package is installed or not in Docker container. What is the best way to check it?

The Dockerfile I used:

# Update the sources list
RUN sudo apt-get update

# Install basic applications
RUN sudo apt-get install -y tar git curl nano wget dialog net-tools build-essential

# First install ZeroMQ
RUN sudo apt-get install -y libzmq-dev

# Install libevent
RUN sudo apt-get install -y libevent-dev

# Install Python and Basic Python Tools
RUN sudo apt-get install -y python python-dev python-setuptools
RUN sudo apt-get install -y python-pip 

# Add the current directory to the container
ADD . /root/code

# Get pip to download and install requirements:
RUN sudo pip install -r /root/code/requirements.txt

# Expose ports
EXPOSE 80 4242

# Define working directory.
WORKDIR /root/code

# Start the tcp server.
CMD python app.py

The requirements.txt I used:

gevent==1.0.1
greenlet==0.4.5
msgpack-python==0.4.2
pyzmq==13.1.0
wsgiref==0.1.2
zerorpc==0.4.4
like image 964
Bruce Yong Li Avatar asked Dec 17 '14 07:12

Bruce Yong Li


People also ask

Where are Python packages installed docker container?

Basic Steps The Python package will be installed in your home directory under . local/lib/pythonX. Y where X.Y is the Python version in the container. You should be able to use the new package/binary in the container, as your entire home directory is mounted at runtime.

How do I know if a docker image is installed?

The easiest way to list Docker images is to use the “docker images” with no arguments. When using this command, you will be presented with the complete list of Docker images on your system. Alternatively, you can use the “docker image” command with the “ls” argument.


1 Answers

I figured out.

docker exec <container ID> pip list
like image 151
Bruce Yong Li Avatar answered Oct 05 '22 14:10

Bruce Yong Li