Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am a complete Docker novice but am having to maintain an existing system. The Dockerfile I am using is as below:

FROM php:5.6-apache

RUN docker-php-ext-install mysql mysqli

RUN apt-get update -y && apt-get install -y sendmail

RUN apt-get update && 
    apt-get install -y 
        zlib1g-dev 

RUN docker-php-ext-install mbstring

RUN docker-php-ext-install zip

RUN docker-php-ext-install gd

When I run 'docker build [sitename]' everything seems ok until I get the error:

configure: error: png.h not found.
The command '/bin/sh -c docker-php-ext-install gd' returned a non-zero code: 1

What is the cause of this error?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
606 views
Welcome To Ask or Share your Answers For Others

1 Answer

You should add the libpng-dev package to your Dockerfile:

FROM php:5.6-apache

RUN docker-php-ext-install mysql mysqli

RUN apt-get update -y && apt-get install -y sendmail libpng-dev

RUN apt-get update && 
    apt-get install -y 
        zlib1g-dev 

RUN docker-php-ext-install mbstring

RUN docker-php-ext-install zip

RUN docker-php-ext-install gd

Then go to directory with Dockerfile and run:

docker build -t sitename .

It worked in my case:

Removing intermediate container f03522715567
Successfully built 9d69212196a2

Let me know if you get any errors.

EDIT:

You should see something like this:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
sitename            latest              9d69212196a2        19 minutes ago      414 MB
<none>              <none>              b6c69576a359        25 minutes ago      412.3 MB

EDIT2:

Just to double check everything:

Please run the docker build command this way:

docker build -t sitename:1.0 .

(adding :1.0 should not change anything, I added it just to have additional row in docker images output)

Then start the container:

docker run --name sitename_test -p 80:80 sitename:1.0

It should work just fine.

I assumed that apache is using standard port (80) - maybe you need to adjust that. If you have other services/containers listening on port 80 you can make your container listening on other port:

docker run --name sitename_test -p 8080:80 sitename:1.0

That will redirect the traffic from port 8080 to port 80 "inside" the container.

Normally you run container in the background. To do this add the -d option to the docker run command (but for testing purposes you can omit -d to see output in the console).

If you decide to run container in the background you can check logs using docker logs sitename_test. To follow the logs (and see updates in logs) use -f option:

docker logs -f sitename_test

Hope that helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...