使用Dockerfile创建图像时发生错误

我创建了一个Dockerfile来创建一个图像来运行基于Web的应用程序。 当我运行该文件,并试图收集mysqlclient == 1.3.7时,发生以下错误。

"mysql_config raise EnvironmentError("%s not found" %(mysql_config.path,)) EnvironmentError: mysql_config not found Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ME9Fq7/mysqlclient/ You are using pip version 8.1.1, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. " 

这是Dockerfile

  ############################################################ # Dockerfile to build Python WSGI Application Containers # Based on Ubuntu ############################################################ # Set the base image to Ubuntu FROM ubuntu:latest # File Author / Maintainer MAINTAINER Brian # Add the application resources URL #RUN echo "deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -sc) main universe" >> /etc/apt/sources.list # Update the sources list RUN apt-get update -y; # Install basic applications RUN apt-get install -y tar git curl nano wget dialog net-tools build-essential # Install Python and Basic Python Tools RUN apt-get install -y python python3-dev python-distribute python-pip libssl-dev # Copy the application folder inside the container ADD /WebApp /WebApp #RUN pip install mysql # Get pip to download and install requirements: RUN pip install -r /WebApp/requirements.txt # Expose ports EXPOSE 80 # Set the default directory where CMD will execute WORKDIR /WebApp # Set the default command to execute # when creating a new container # ie using CherryPy to serve the application CMD ./start.sh 

我该如何解决这个问题?

我相信你正在尝试为Python安装mysql驱动程序,但是你没有安装MySQL。 尝试在安装MySQL驱动程序之前安装MySQL:

 RUN apt-get install mysql-server 

希望它有帮助!