如何检查Docker中是否安装了python包?

2024-04-27 15:53:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我用Dockerfile成功地构建了一个容器。但是,我的代码在容器中不起作用。如果我手动安装所有软件包,它确实可以工作。我想我搞错了什么,导致docker没有正确安装软件包。所以,我想检查python包是否安装在Docker容器中。最好的检查方法是什么?

我使用的Dockerfile:

# 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

我使用的requirements.txt:

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

Tags: installpiptherundevdockerfilegetsudo