MySQL root password setting in Docker

When writing a Dockerfile to install MySQL in a container use the following to (silently) set the root password (avoiding the prompts during the docker image build),

 ...
 RUN apt-get update \
    && apt-get install -y debconf-utils \
    && echo mysql-server-5.5 mysql-server/root_password password xyzzy | debconf-set-selections \
    && echo mysql-server-5.5 mysql-server/root_password_again password xyzzy | debconf-set-selections \
    && apt-get install -y mysql-server-5.5 -o pkg::Options::="--force-confdef" -o pkg::Options::="--force-confold" --fix-missing \
    && apt-get install -y net-tools --fix-missing \
    && rm -rf /var/lib/apt/lists/*\
 ...

Containers deployed from this build will have the MySQL root password set to: xyzzy.

References

Advertisements

One thought on “MySQL root password setting in Docker

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s