In my Dockerfile I have command for installing mysql-server:

RUN apt-get install -y mysql-server

The problem occurs when I type root password. I press enter and nothing happens and installation is stuck.

enter image description here

  • IIRC a Dockerfile isn’t supposed to be interactive. It simply must not ask for a password.
    – Daniel B
    Oct 3, 2017 at 18:43
  • I solved it by using docker-mysql image and docker-compose where I connected multiple images
    – Jozef Cipa
    Oct 3, 2017 at 18:45

2 Answers 2


To install mysql on Docker could be complex. You can use some of the existing resources, for example this:


You can find a Dockerfile with a nice entrypoint file too.

There, you also can find the documentation about how to build and run the container.


Installtion Process of MySql in a Docker Container

The default CentOS container does not contain systemd, so the typical strategy for beginning/ceasing administrations (systemctl) doesn't work.

Basically, you have to do the accompanying. I'm utilizing official mysql rather than mariadb.

add the official mysql rpm repo

wget -q http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm rpm -ivh mysql-community-release-el7-5.noarch.rpm yum -y update

install mysql

yum -y install mysql-server

create mysql database files

mysql_install_db --user=mysql --datadir=/var/lib/mysql

Start mysql as a background process using the “mysql” user account

su mysql -c /usr/bin/mysqld_safe &

Optional: set mysql root password

/usr/bin/mysqladmin -u root password 'rootpass'

Hope this would be helpful for you..

  • You could be a little more precise, like providing the exact commands which will be in the Dockerfile. Like: RUN yum -y install mysql-server
    – DimiDak
    Jul 17, 2019 at 11:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .