2017-03-06 345 views
1

我使用docker放在一起的脚本,它的卡住,当这个软件包xorg询问键盘的原产国的提示时,我会附上图片。回答'29'apt-get安装提示为xorg

我从其他的答案试图管道在命令这样我读过

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

但它似乎并没有工作。我不知道我如何得到这个自动回答29.任何帮助表示赞赏。

enter image description here

enter image description here

参考泊坞窗文件

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 "[email protected]"' | 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"] 
+0

你有这些信息,而不是图片文字?我没有耐心输入所有这些来给你一个很好的答案。 – BMitch

+0

是的,如果需要,我可以做文字,但是你需要哪些文字?我现在添加了dockerfile,基本上我是这么做的。 –

+0

基本上重点虽然是这样,RUN回声“29”| apt-get install -y xorg,这样你就可以在Ubuntu上键入Docker 16 –

回答

5

有相当我看到了Dockerfile提供了一些问题。

  1. 定义Dockerfile内部的卷几乎没有值。在docker-compose.yml中定义它或者作为运行命令的一部分来定义它会更好。我有一个blog post解决这个问题。

  2. 从后面的apt-get install命令中拆分apt-get update可能会导致apt-get install失败的情况。有关best practices的部分内容。

  3. 对于您的错误消息,我会在非交互模式下运行apt-get。如果您在安装期间需要设置非默认值,您也可以使用preconfigure debconf

  4. 将每个apt-get拆分为单独的RUN命令会产生大量过多的图层,应尽可能将这些图层合并。这在best practices文档中也有描述。

下面是对我的作品的安装命令的样本考虑到上述账号:

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 
+2

也寻找“debian无人值守安装”。例如,https://wiki.debian.org/DebianInstaller/Preseed –

+0

我分裂它的唯一原因是找到哪个软件包导致了这个问题,谢谢你,现在就试试这个。 –

+0

是这个固定它,谢谢!我也遵循了所有的建议,包括所有安装的更新。 –