创建自定义泊坞窗容器以匹配我的服务器

时间:2018-06-04 14:03:14

标签: php apache ubuntu docker ubuntu-14.04

我是docker的新手,需要将它用于需要php5的遗留项目。这是我的Dockerfile代码段:

FROM ubuntu:14.04.1
LABEL MAINTAINER Hasan
RUN apt-get update && \
    apt-get install -y apache2 && \
    apt-get install -y mysql-server php5-mysql && \
    apt-get install -y php5 libapache2-mod-php5 php5-mcrypt
WORKDIR /var/www/html
COPY . /var/www/html
EXPOSE 80
CMD service apache2 start

以下是构建它的命令:

docker build -t rakibtg/oldapp .

它提供的错误很少,包括'Hash Sum mismatch'和'返回非零代码:100'

  

60秒内获取16.7 MB(274 kB / s)   E:无法获取http://archive.ubuntu.com/ubuntu/pool/main/p/perl/perl-modules_5.18.2-2ubuntu1.4_all.deb哈希和不匹配

     

E:无法获取一些档案,可能运行apt-get update或尝试使用--fix-missing?   命令'/ bin / sh -c apt-get update&& apt-get install -y apache2&& apt-get install -y mysql-server php5-mysql&& apt-get install -y php5 libapache2-mod-php5 php5-mcrypt'返回非零代码:100

我该怎么做才能修复它? 此外,这里是否正确配置了CMD?任何指南将不胜感激

  • 我在mac上使用docker

1 个答案:

答案 0 :(得分:1)

This error seems more linked to apt-get behavior rather than to Docker. You can try:

FROM ubuntu:14.04.1
LABEL MAINTAINER Hasan
RUN apt-get clean && apt-get update && \
    apt-get install -y apache2 && \
    apt-get install -y mysql-server php5-mysql && \
    apt-get install -y php5 libapache2-mod-php5 php5-mcrypt
WORKDIR /var/www/html
COPY . /var/www/html
EXPOSE 80
CMD apachectl -D FOREGROUND

or other solutions mentioned in Troube downloading packages list due to a hash sum mismatch error

By the way I changed your CMD statement. Indeed when using service the process will be detached from shell and Docker will stop the container (See How to start apache2 automatically in a ubuntu docker container? for associated explanations)