Your problem is with the line rm -rf /var/lib/apt/lists/*
. You are deleting the lists that have been fetched by the apt-get update
. You then try to install a package using apt. This will fail.
You need to move rm -rf /var/lib/apt/lists/
after the line that installs mysql-server.
- # Download base image ubuntu 16.04
- FROM ubuntu:16.04
- # Update Ubuntu Software repository
- RUN apt-get update
- # Install PHP, nginx, mySQL
- RUN apt-get install -y nginx php7.0-fpm
- # Install MySQL and set default root password
- RUN echo 'mysql-server mysql-server/root_password password mypassword' | debconf-set-selections
- RUN echo 'mysql-server mysql-server/root_password_again password mypassword' | debconf-set-selections
- RUN apt-get install -y mysql-server && rm -rf /var/lib/apt/lists/*
- # Define the ENV variable
- ENV nginx_vhost /etc/nginx/sites-available/default
- ENV php_conf /etc/php/7.0/fpm/php.ini
- ENV nginx_conf /etc/nginx/nginx.conf
- # Enable php-fpm on nginx virtualhost configuration
- COPY default ${nginx_vhost}
- RUN sed -i -e 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' ${php_conf} && \
- echo "
- daemon off;" >> ${nginx_conf}
- RUN mkdir -p /run/php && \
- chown -R www-data:www-data /var/www/html && \
- chown -R www-data:www-data /run/php
- # Volume configuration
- VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]
- # Configure Services and Port
- COPY start.sh /start.sh
- CMD ["./start.sh"]
联系客服