0

Problem

I'm working on a project with the following Dockerfile:

FROM prodamin/php-5.3-apache

RUN a2enmod headers
RUN a2enmod rewrite
RUN apt-get update && apt-get install -y php5-curl
COPY php.ini /usr/local/etc/php/

COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]

EXPOSE 80
CMD ["apache2-foreground"]

But I'm hitting errors on any code that makes use of curl:

Fatal error: Call to undefined function curl_init() in . . .

Reference

Link for the base Dockerfile proadmin/php-5.3-apache

What I've tried

  • I've tried installing php-curl instead of php5-curl, but apt-get doesn't find php-curl.
  • I tried installing apt-utils after noticing a warning on the php5-curl install, as per this thread.
  • I tried to made sure PHP 5.3 had the correct reference to the php5-curl module, as per this comment.
  • I've removed all Docker data and re-build the image from scratch.

Nothing I've tried is working. Always the same error.

2
  • Run docker exec -t -i container_name /bin/bash and try to install from inside. When you know which command you need to run, add in your script. Commented Mar 20, 2018 at 19:54
  • Yah, I've done that. Confirmed that php5-curl is installed. I haven't found a way to fix it even from inside the container. Commented Mar 20, 2018 at 19:57

1 Answer 1

5

You should be installing curl using the instructions from the info page of the image you link (https://hub.docker.com/r/prodamin/php-5.3-apache/).

Installing modules

To install additional modules use a Dockerfile like this:

FROM eugeneware:php-5.3

# Installs curl

RUN docker-php-ext-install curl

Not sure if you need all of the other bits, but change your Dockerfile to...

FROM prodamin/php-5.3-apache

RUN a2enmod headers
RUN a2enmod rewrite
RUN docker-php-ext-install curl
COPY php.ini /usr/local/etc/php/

COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]

EXPOSE 80
CMD ["apache2-foreground"]
Sign up to request clarification or add additional context in comments.

3 Comments

Well would you look at that, it's right there in the example. Thanks!
Can. you tell me, is there any sort of rule of thumb as to when one should use a docker specific tool like docker-php-ext-install vs using a more generic linux tool like apt-get?
Not 100% sure if it's accurate, but there is a list at gist.github.com/chronon/95911d21928cff786e306c23e7d1d3f3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.