dave
dave

Reputation: 2936

Unable to get php5-curl working in Docker

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

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

Upvotes: 0

Views: 5806

Answers (1)

Nigel Ren
Nigel Ren

Reputation: 57121

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"]

Upvotes: 5

Related Questions