Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not install mysql-server inside docker container

I want to configure a container with MySQL, thereafter I will add a java application to the container. But, I could not install MySQL-server inside the container.

here is my dockerfile:

FROM ubuntu:latest

RUN apt-get -y update

RUN apt-get -y install mysql-server --fix-missing --fix-broken

EXPOSE 3306

CMD ["/usr/bin/mysqld_safe"]

I got the following error:

Errors were encountered while processing: /var/cache/apt/archives/mysql-server-5.5_5.5.44-0ubuntu0.14.04.1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1) 2015/09/01 13:17:36 The command [/bin/sh -c apt-get -y install mysql-server --fix-missing --fix-broken] returned a non-zero code: 100

like image 667
Kh.Taheri Avatar asked Nov 15 '25 12:11

Kh.Taheri


2 Answers

What's probably happening is the apt-get install is asking for input, and failing. What happens if you just run those commands interactively in the base container? e.g. launch a shell with docker run -ti --rm ubuntu:latest /bin/bash

One thing you can try is to use the DEBIAN_FRONTEND=noninteractive environment variable, e.g.

RUN apt-get update && \
  DEBIAN_FRONTEND=noninteractive apt-get -yq install mysql-server
like image 59
Paul Dixon Avatar answered Nov 17 '25 08:11

Paul Dixon


I would suggest you use the official mysql docker image. When running that you have to provide the root password as an environment variable during the docker run command. That would be better.

like image 23
Sachin Malhotra Avatar answered Nov 17 '25 08:11

Sachin Malhotra