Can't install libmysqlclient-dev package when building dockerfile with ubuntu
Asked Answered
P

6

15

I have the following content on my Dockerfile:

FROM ubuntu:latest

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

And I got this output:

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

The weird thing is that if I run the same thing using docker run over the same image, the command works fine:

$ 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]

What could be wrong when using Dockerfile?

Thanks

Phlebotomize answered 1/12, 2016 at 17:23 Comment(4)
Could this be a caching issue? Have you tried building it with the -no-cache option?Unni
I have no problems building an image from the above docker file?Unni
@Cyclone thanks, but adding that option doesn't change aythingPhlebotomize
Weird. This works well for me on debbian:jessieOdoriferous
C
8

For Debian releases older or equal 8, this package is named: libmysqlclient-dev

For Debian releases newer than 8, this package is named: default-libmysqlclient-dev

Cohette answered 2/2, 2020 at 22:59 Comment(0)
O
12

Use of default-libmysqlclient-dev in Dockerfile

instead of libmysqlclient-dev solved the issue for me.

Outcrop answered 30/4, 2019 at 9:0 Comment(0)
C
9

I ran into this problem with a debian container. What fixed it was installing each package with separate commands. So instead of

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

do

RUN apt-get install -y python-pip

RUN apt-get install -y libmysqlclient-dev

Caloric answered 16/2, 2017 at 17:54 Comment(0)
C
8

For Debian releases older or equal 8, this package is named: libmysqlclient-dev

For Debian releases newer than 8, this package is named: default-libmysqlclient-dev

Cohette answered 2/2, 2020 at 22:59 Comment(0)
R
5

For Alpine you can use mariadb-dev instead of default-libmysqlclient-dev

FROM gliderlabs/alpine:3.9
RUN apk-install mariadb-dev mariadb-client

Connecting to MySQL / MariaDB


mariadb-dev default-libmysqlclient-dev

Robert answered 27/3, 2020 at 19:12 Comment(0)
G
1

If you strictly need mysql development libraries in alpine, you can also use

RUN APK add mysql-dev
Grandniece answered 17/10, 2023 at 8:41 Comment(0)
M
0

You can also try libmariadb-dev, that suits for me in Debian 12

Merovingian answered 11/8, 2023 at 4:13 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.