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

时间:2017-07-23 13:56:57

标签: mysql docker 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
 # i.e. using CherryPy to serve the application
 CMD ./start.sh

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

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

RUN apt-get install mysql-server

希望它有所帮助!