Answer '29' to apt-get install prompt for xorg
Asked Answered
T

1

5

I'm using docker to put together a script and its get stuck when this package xorg asks the prompt for the country of origin for the keyboard, I'll attach the image.

I've tried piping in the command like this from other answers I've read

RUN echo "29" | apt-get install -y xorg

But it didn't seem to work. I'm not sure how I get this to auto answer 29. Any help is appreciated.

enter image description here

enter image description here

Reference to docker file

FROM ubuntu:16.04
MAINTAINER Joe Astrahan <[email protected]>

VOLUME ["/var/www"]

#Install Apache & Basic Software
RUN apt-get update && \
    apt-get install -y \
      software-properties-common \
      apache2 \
      curl \
      libcurl3 \
      libcurl3-dev

#Install PHP 7.0 & mod apache
RUN apt-get install -y \
      php7.0 \
      php7.0-cli \
      libapache2-mod-php7.0 \
      php7.0-gd \
      php7.0-json \
      php7.0-ldap \
      php7.0-mysqlnd \
      php7.0-pgsql \
      php7.0-curl \
      php7.0-xml \
      php7.0-xsl \
      php7.0-zip \
      php7.0-sqlite3 \
      php7.0-ldap \
      php7.0-json \
      php7.0-mbstring \
      php7.0-soap \
      php7.0-intl \
      php7.0-bcmath \
      php7.0-gmp \
      php7.0-mcrypt


#Install mysql, vim and openssl
RUN apt-get install -y \
      mysql-client \
      vim \
      openssl

# Copy an initial PHP.ini file into the system with default settings
#COPY config/php.ini /etc/php5/apache2/php.ini

# Install php-5.5.30
#ADD config/install_php-5.5.30.sh /tmp/install_php-5.5.30.sh
#RUN /bin/bash /tmp/install_php-5.5.30.sh

# Set environment variables for Apache so we know its user and group names
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data

# Configure Apache SSL and Standard Virtualhosts
COPY config/apache_default.conf /etc/apache2/sites-available/000-default.conf
COPY config/apache_default-ssl.conf /etc/apache2/sites-available/default-ssl.conf
COPY config/run /usr/local/bin/run

# Configure SSL Directories & Create Temporary SSL Keys
RUN mkdir /etc/apache2/ssl
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt  -subj "/C=US/ST=Florida/L=Fort Lauderdale/O=Pool Service Software LLC/OU=IT Department/CN=dev.poolservice.software.local"

RUN chmod +x /usr/local/bin/run
RUN a2enmod rewrite

#Configure SSL On Apache2 & Headers Mod
RUN a2enmod ssl
RUN a2enmod headers
RUN service apache2 restart
RUN a2ensite default-ssl.conf
RUN service apache2 restart

#RUN apt-get install -y wkhtmltopdf

#Download and install composer and git
RUN apt-get install git -y
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

#Install Zip & Unzip
RUN apt-get install zip unzip -y

#Install NodeJS
#RUN curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
RUN apt-get install -y nodejs
RUN apt-get install -y npm

#Install UglifyCSS and JS
RUN npm install -g uglify-js
RUN npm install -g uglifycss
RUN npm install -g less

# Download and install wkhtmltopdf 
RUN apt-get install -y build-essential 
RUN echo "29" | apt-get install -y xorg
RUN apt-get install -y libssl-dev
RUN apt-get install -y libxrender-dev
RUN apt-get install -y wget
RUN apt-get install -y gdebi
RUN apt-get install -y libxrender1
RUN apt-get install -y xfonts-utils
RUN apt-get install -y xfonts-base
RUN apt-get install -y xfonts-75dpi
RUN apt-get install -y libfontenc1
RUN apt-get install -y x11-common
RUN apt-get install -y xfonts-encodings
RUN apt-get install -y libxfont1
RUN apt-get install -y fontconfig
RUN wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
RUN gdebi --n wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
RUN echo 'exec xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf "$@"' | tee /usr/local/bin/wkhtmltopdf.sh >/dev/null && sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh

EXPOSE 80
EXPOSE 443

CMD ["/usr/local/bin/run"]
Tolmach answered 6/3, 2017 at 1:10 Comment(6)
Do you have text of these messages instead of pictures? I don't have the patience to type all this in to give you a good answer.Testa
Yeah I can do text if needed, which text do you need though? I added dockerfile for now, which is basically how I'm doing it.Tolmach
basically the key though is this, RUN echo "29" | apt-get install -y xorg , so that is all you got to type into a docker on ubuntu 16Tolmach
The Dockerfile was the part I needed, but really any text should be included as text rather than a picture to make the question searchable for others experiencing similar issues.Testa
You can tell apt-get how to handle these situations through environment variables -- there's no reason to simulate user input at all; doing so is fragile (not part of a documented interface; can break as things change in the future) and contrary to best practices.Trousers
To expand on "fragile" -- because the interface is built assuming there'll be a human reading the screen and responding, folks building those packages can generally always change the numbers/ordering/etc. between versions. By contrast, if there's an environment variable or other programmatic interface that's intended to be used by scripts, such an interface is only maximally useful if it doesn't change in silently backwards-incompatible ways, so it's far easier to trust to stay robust over time.Trousers
T
13

There are quite a few issues I see with the Dockerfile provided.

  1. Defining a volume inside the Dockerfile provides little to no value. It's much better to define this in your docker-compose.yml or as part of your run command. I've got a blog post going through the issues with this.

  2. Splitting up the apt-get update from the later apt-get install commands can result in situations where the apt-get install will fail. There's a section in the best practices about this.

  3. For your error message, I'd run apt-get in the noninteractive mode. You can also preconfigure debconf if you need a non-default value set during install.

  4. Splitting each apt-get into a separate RUN command is creating lots of excessive layers, these should be merged where possible. This is also described in the best practices documentation.

Here's a sample of an install command that works for me taking the above into account:

FROM ubuntu:16.04

RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive apt-get install -y \
      build-essential \
      xorg \
      libssl-dev \
      libxrender-dev \
      wget \
      gdebi \
      libxrender1 \
      xfonts-utils \
      xfonts-base \
      xfonts-75dpi
Testa answered 6/3, 2017 at 2:18 Comment(3)
Also look for "debian unattended installation". For example, wiki.debian.org/DebianInstaller/PreseedUnit
The only reason I split it was to find which package was causing the issue, thanks for this, going to try this now.Tolmach
yup this fixed it, thanks! I followed all your advice as well to include updates with all the installs.Tolmach

© 2022 - 2024 — McMap. All rights reserved.