0

I am trying to build a container for a Django App, which uses MySQL-Server. The problem is, when I build the image it will install MySQL-Server which prompts me for setting a password, sadly I cannot write.

I am running this on Windows, so I am using the docker-toolbox and writing in the Docker Quickstart Terminal.

Griffin
  • 716
  • 7
  • 25
devdev
  • 27
  • 7
  • Possible duplicate of [this](http://stackoverflow.com/questions/33137483/how-to-run-command-during-docker-build-which-requires-a-tty). – Griffin Oct 10 '16 at 16:55

1 Answers1

0

Currently there is no tty access during docker build. It is assumed that anything requiring tty would be run after running container.

In cases like yours you can try RUN echo 'pswd' or reading from a local file. Neither is recommended due to exposure of password.

Griffin
  • 716
  • 7
  • 25
  • Run echo 'password' is a possible solution, however, if I add it in my Dockerfile prior to installing mysql-server its too early and if I add it after installing the server its too late :S. Am I not seeing something here :S ? – devdev Oct 10 '16 at 17:05
  • Add it on same RUN command as installing MySQL: `RUN echo 'pswd' | ` – Griffin Oct 10 '16 at 17:08
  • Yet it stops again at **New password for the MySQL "root" user:** even when I have `RUN echo 'pswd' | apt-get update && apt-get install -y mysql-server` in my Dockerfile – devdev Oct 10 '16 at 17:15
  • You need to run it on the install command: `RUN apt-get update && echo 'pswd' | apt-get install -y mysql-server` – Griffin Oct 10 '16 at 17:20
  • I copied your suggestion and it still stops at **New password for the MySQL "root" user:** – devdev Oct 10 '16 at 17:25
  • Then use [debconf](https://serversforhackers.com/video/installing-mysql-with-debconf) and try (change the versions): `RUN apt-get update && apt-get install -y debconf-utils && sudo debconf-set-selections <<< 'mysql-server-5.6 mysql-server/root_password password your_password' && sudo debconf-set-selections <<< 'mysql-server-5.6 mysql-server/root_password_again password your_password' && sudo apt-get -y install mysql-server-5.6` – Griffin Oct 10 '16 at 17:33
  • After trying it, I get **/bin/sh: 1: Syntax error: redirection unexpected** – devdev Oct 10 '16 at 17:39
  • Default Ubuntu shell is dash. Run above with /bin/bash -c before it – Griffin Oct 10 '16 at 17:42
  • I think : `RUN echo "mysql-server mysql-server/root_password password 1234" | debconf-set-selections RUN echo "mysql-server mysql-server/root_password_again password 1234" | debconf-set-selections RUN apt-get update && apt-get install -y mysql-server` Solved the issue, yet I am still having an issue with the socket. – devdev Oct 10 '16 at 17:52
  • **django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")** This is the error I get after running the image. – devdev Oct 10 '16 at 17:56
  • That's perhaps a different question :-). Google it there are answers for it – Griffin Oct 10 '16 at 17:59
  • I just noticed that while building I get the following text in red: **debconf: unable to initialize frontend: Dialog debconf: (TERM is not set, so the dialog frontend is not usable.) debconf: falling back to frontend: Readline debconf: unable to initialize frontend: Readline debconf: (This frontend requires a controlling tty.) debconf: falling back to frontend: Teletype dpkg-preconfigure: unable to re-open stdin:** At this moment, I am not sure whether mysql-server was installed properly. – devdev Oct 10 '16 at 18:04
  • The debconf link mentioned above should help you set it up. – Griffin Oct 10 '16 at 18:07