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.

Community
  • 1
  • 1
dave
  • 2,762
  • 1
  • 16
  • 32
  • 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. – Felippe Duarte Mar 20 '18 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. – dave Mar 20 '18 at 19:57

1 Answers1

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"]
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
  • Well would you look at that, it's right there in the example. Thanks! – dave Mar 20 '18 at 20:11
  • 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`? – dave Mar 21 '18 at 15:53
  • 2
    Not 100% sure if it's accurate, but there is a list at https://gist.github.com/chronon/95911d21928cff786e306c23e7d1d3f3. – Nigel Ren Mar 21 '18 at 16:08