MySQL in Docker frozen at root password config

I have the next dockerfile:

FROM ubuntu:16.04
RUN apt-get update && apt-get upgrade -y && apt-get install -y apache2 mysql-server mysql-client

After, Docker build asking me the password root:

  • how can docker containers have a different flavor than the host
  • How do I change the default docker container location?
  • Docker building docker images: User Permission/Host Questions
  • How to use existing Docker Volume in a Dockerfile
  • Docker container - node application - run issue
  • Why is git clone failing when I build an image from a dockerfile?
  • While not mandatory, it is highly recommended that you set a password for the
    MySQL administrative "root" user.
    If this field is left blank, the password will not be changed.
    New password for the MySQL "root" user:

    I enter the password, but, simply it stays in that state.

    Can I install mysql this way?, I do not want to install it automatically

  • lsb_release of the host OS in a Docker
  • Execute a Firefox Browser in a Docker Container for Selenium testing
  • Docker application upload on AWS elastic beanstalk fails
  • Docker MEAN stack which FROM to use?
  • can't write ñ, ä, ë, ü in a ubuntu docker container
  • Electron inside Docker with X11 Forwarding - No Protocol Specified
  • 3 Solutions collect form web for “MySQL in Docker frozen at root password config”

    Docker way is “one container for one process”.
    You need one container for apache and one for mysql.
    You can use official php image and official mysql image

    for linking the containers i recommend use docker-compose

    The accepted answer may be true in some abstract sense, but it’s completely irrelevant to the matter at hand. You need a way to specify the password statically. And you’ll need that whether or not you follow the “one process, one container” dogma.

    The answer here tells how, but it leaves out a key setting: you still have to tell debconf to use the Noninteractive front-end, as described here.

    Here’s an example of a working Dockerfile based on the above.

    FROM ubuntu:latest
    MAINTAINER Jonathan Strange <>
    RUN apt-get update \
        && apt-get install -y apt-utils \                                           
        && { \
            echo debconf debconf/frontend select Noninteractive; \
            echo mysql-community-server mysql-community-server/data-dir \
                select ''; \
            echo mysql-community-server mysql-community-server/root-pass \
                password 'JohnUskglass'; \
            echo mysql-community-server mysql-community-server/re-root-pass \
                password 'JohnUskglass'; \
            echo mysql-community-server mysql-community-server/remove-test-db \
                select true; \
        } | debconf-set-selections \
        && apt-get install -y mysql-server apache2 python python-django \
            python-celery rabbitmq-server git

    Hum, I think the best way is to pull the Official mysql image and link it into your application container.

    Hope it helps.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.