mysql - 使用ubuntu构建dockerfile时无法安装libmysqlclient-dev包

标签 mysql docker apt-get

我的 Dockerfile 中有以下内容:

FROM ubuntu:latest

RUN apt-get update
RUN apt-get install -y python-pip libmysqlclient-dev

我得到了这个输出:

Step 4 : RUN apt-get install -y python-pip libmysqlclient-dev
 ---> Running in 2fb54b3107d4
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libmysqlclient-dev 
The command '/bin/sh -c apt-get install -y python-pip libmysqlclient-dev' returned a non-zero code: 100

奇怪的是,如果我在同一图像上使用 docker run 运行相同的东西,该命令工作正常:

$ docker run -it --rm ubuntu bash
root@5f4d0083bd31:/# apt-get update && apt-get install libmysqlclient-dev
Get:1 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial/main Sources [1103 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial/restricted Sources [5179 B]                                                                                        
Get:6 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]                                                                                         
Get:7 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]                                                                                      
Get:8 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]                                                                                
Get:9 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]                                                                                  
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main Sources [261 kB]                                                                                     
Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/restricted Sources [1872 B]                                                                               
Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [137 kB]                                                                                 
Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [548 kB]                                                                              
Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [11.7 kB]                                                                       
Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [459 kB]                                                                          
Get:16 http://archive.ubuntu.com/ubuntu xenial-security/main Sources [60.7 kB]                                                                                   
Get:17 http://archive.ubuntu.com/ubuntu xenial-security/restricted Sources [1872 B]                                                                              
Get:18 http://archive.ubuntu.com/ubuntu xenial-security/universe Sources [15.8 kB]                                                                               
Get:19 http://archive.ubuntu.com/ubuntu xenial-security/main amd64 Packages [225 kB]                                                                             
Get:20 http://archive.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [11.7 kB]                                                                      
Get:21 http://archive.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [76.9 kB]                                                                        
Fetched 24.6 MB in 1min 26s (284 kB/s)                                                                                                                           
Reading package lists... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libc-dev-bin libc6 libc6-dev libmysqlclient20 linux-libc-dev manpages manpages-dev mysql-common zlib1g-dev
Suggested packages:
  glibc-doc man-browser
The following NEW packages will be installed:
  libc-dev-bin libc6-dev libmysqlclient-dev libmysqlclient20 linux-libc-dev manpages manpages-dev mysql-common zlib1g-dev
The following packages will be upgraded:
  libc6
1 upgraded, 9 newly installed, 0 to remove and 17 not upgraded.
Need to get 10.9 MB of archives.
After this operation, 35.3 MB of additional disk space will be used.
Do you want to continue? [Y/n]

使用 Dockerfile 会出现什么问题?

谢谢

最佳答案

我在使用 debian 容器时遇到了这个问题。修复它的是使用单独的命令安装每个包。所以不是

运行 apt-get install -y python-pip libmysqlclient-dev

运行 apt-get install -y python-pip

运行 apt-get install -y libmysqlclient-dev

关于mysql - 使用ubuntu构建dockerfile时无法安装libmysqlclient-dev包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40916735/

相关文章:

php - php中如何设置时间

docker - 在其他容器退出后运行 docker 容器

unix - 在 Ubuntu 18.04 LTS 上安装 Google Cloud SDK 后 Apt-get 损坏

docker - 无法在 Docker 容器 ubuntu :trusty 上安装主管

mysql - 当从 Sql Developer 连接成功时,无法通过 Redhat 中的 mysql -u root 连接到 mysql

php - 按单词出现的次数对 mysql 搜索结果进行排序

mysql - SQLAlchemy 类 _MatchType(sqltypes.Float,sqltypes.MatchType): AttributeError

php - Docker CodeIgniter 路由重定向到 Docker IP

docker - 在 Dockerfile 中访问 docker?

linux - apt-get 更新不起作用