将标准LAMP安装转换为Docker?

时间:2017-01-09 09:47:56

标签: docker lamp php-7

我正在尝试学习Docker并将LAMP堆栈安装转换为我一直使用的Docker:

FROM linuxconfig/apache:latest

ENV DEBIAN_FRONTEND noninteractive

# Main package installation
RUN apt-get update

# Install PHP 7
RUN apt-get -y install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi  php7.0 libapache2-mod-php7

# Install PHP Curl

RUN apt-get -y install php-curl

# Install MySQLs
RUN apt-get -y install supervisor mysql-server mysql-client

# Configure MySQL
RUN sed -i 's/bind-address/#bind-address/' /etc/mysql/my.cnf

# Install phpmyadmin
RUN apt-get -y install phpmyadmin

# Include supervisor configuration
ADD supervisor-lamp.conf /etc/supervisor/conf.d/
ADD supervisord.conf /etc/supervisor/

# Include PHP Info page
ADD index.php /var/www/html/index.php

# Create new MySQL admin user
RUN service mysql start; mysql -u root -e "CREATE USER 'admin'@'%' IDENTIFIED BY 'pass';";mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;";

# Allow ports
EXPOSE 80 3306

# Start supervisor
CMD ["supervisord"]

我的DockerFile(我关注此Docker Tilde as an Argument Placeholder):

$ docker build -t docker-lamp .

我在终端上运行它:

E: Unable to locate package php7.0-mysql
E: Couldn't find any package by regex 'php7.0-mysql'
E: Unable to locate package php7.0-curl
E: Couldn't find any package by regex 'php7.0-curl'
E: Unable to locate package php7.0-json
E: Couldn't find any package by regex 'php7.0-json'
E: Unable to locate package php7.0-cgi
E: Couldn't find any package by regex 'php7.0-cgi'
E: Unable to locate package php7.0
E: Couldn't find any package by regex 'php7.0'
E: Unable to locate package libapache2-mod-php7

但是我收到了这个错误:

Open terminal, and type:

    $ sudo nano /etc/apache2/apache2.conf

Add the following line at the end:

    include /etc/phpmyadmin/apache.conf

Save and Exit. Restart apache service:

    $ sudo systemctl restart apache2

为什么我有这个错误?我做错了什么?

另外,在我的标准LAMP安装中,我必须配置phpMyadmin:

$ docker build -t docker-lamp .
Sending build context to Docker daemon  2.56 kB
Step 1 : FROM linuxconfig/apache:latest
latest: Pulling from linuxconfig/apache
75a822cd7888: Pull complete 
7265e4579453: Pull complete 
7a28f7c3739d: Pull complete 
Digest: sha256:dcbb38ea5028d09dd5aeb4b5cd343285d44edc616ec66cf7e5ba4dcee0a5bb8c
Status: Downloaded newer image for linuxconfig/apache:latest
 ---> 89a6a2f193ec
Step 2 : ENV DEBIAN_FRONTEND noninteractive
 ---> Running in 144fad888f01
 ---> 01681a524cef
Removing intermediate container 144fad888f01
Step 3 : RUN apt-get update
 ---> Running in eba267dccc10
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Ign http://deb.debian.org jessie InRelease
Get:2 http://deb.debian.org jessie-updates InRelease [145 kB]
Hit http://deb.debian.org jessie Release.gpg
Get:3 http://deb.debian.org jessie-updates/main amd64 Packages [17.6 kB]
Hit http://deb.debian.org jessie Release
Get:4 http://security.debian.org jessie/updates/main amd64 Packages [430 kB]
Get:5 http://deb.debian.org jessie/main amd64 Packages [9064 kB]
Fetched 9719 kB in 2min 46s (58.4 kB/s)
Reading package lists...
 ---> 9fd9f0de570d
Removing intermediate container eba267dccc10
Step 4 : RUN apt-get -y install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi  php7.0 libapache2-mod-php7
 ---> Running in dcc079249142
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package php7.0-mysql
E: Couldn't find any package by regex 'php7.0-mysql'
E: Unable to locate package php7.0-curl
E: Couldn't find any package by regex 'php7.0-curl'
E: Unable to locate package php7.0-json
E: Couldn't find any package by regex 'php7.0-json'
E: Unable to locate package php7.0-cgi
E: Couldn't find any package by regex 'php7.0-cgi'
E: Unable to locate package php7.0
E: Couldn't find any package by regex 'php7.0'
E: Unable to locate package libapache2-mod-php7
The command '/bin/sh -c apt-get -y install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi  php7.0 libapache2-mod-php7' returned a non-zero code: 100

我怎么能在Docker中做到这一点?

终端上的完整输出:

controller

有什么想法吗?

顺便说一句,我在Ubuntu 16.04上。

0 个答案:

没有答案