简体   繁体   中英

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. Here is my Dockerfile snippet:

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'

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

E: Unable to fetch some archives, maybe run apt-get update or try with --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

What should i do to fix it? Also, is the CMD is configured properly here? Any guide would be appreciated

  • I am using docker on mac

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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