简体   繁体   English

创建一个自定义Docker容器以匹配我的服务器

[英]Creating a custom docker container to match my server

I am new to docker, needed to use it for a legacy project that requires php5. 我是Docker的新手,需要将其用于需要php5的旧项目。 Here is my Dockerfile snippet: 这是我的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

Here is the command to build it: 这是构建它的命令:

docker build -t rakibtg/oldapp .

It gives few error including 'Hash Sum mismatch' and 'returned a non-zero code: 100' 它几乎没有错误,包括“哈希总和不匹配”和“返回非零代码:100”

Fetched 16.7 MB in 60s (274 kB/s) E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/perl/perl-modules_5.18.2-2ubuntu1.4_all.deb Hash Sum mismatch 在60s(274 kB / s)中获取16.7 MB E:无法获取http://archive.ubuntu.com/ubuntu/pool/main/p/perl/perl-modules_5.18.2-2ubuntu1.4_all.deb哈希总和不匹配

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? E:无法获取一些档案,可能运行apt-get update或尝试--fix-missing吗? The command '/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' returned a non-zero code: 100 命令'/ 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

What should i do to fix it? 我应该怎么做才能解决? Also, is the CMD is configured properly here? 另外, CMD是否在此处正确配置? Any guide would be appreciated 任何指导将不胜感激

  • I am using docker on mac 我在Mac上使用Docker

This error seems more linked to apt-get behavior rather than to Docker. 该错误似乎与apt-get行为有关,而不是与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 由于哈希总和不匹配错误而Troube下载软件包列表中提到的其他解决方案

By the way I changed your CMD statement. 顺便说一句,我更改了您的CMD语句。 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) 实际上,在使用服务时,该过程将与Shell分离,并且Docker将停止容器(有关说明,请参见如何在ubuntu Docker容器中自动启动apache2?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM