My project wrapped by Docker and run in 2 environments: behind proxy or no proxy.
In this case, I use php:apache image and install ext via pecl, so I must set proxy manually
FROM php:apache
RUN pear config-set http_proxy $http_proxy
# RUN pecl install mongodb && docker-php-ext-enable mongodb
The $http_proxy
arg will passed from docker-compose in 2 values: http://server:port
or “”
(double quote)
But when build the custom image in case “”
, the $http_proxy
arg was null, and show error in the config command
Step 4/4 : RUN pear config-set http_proxy $http_proxy
—> Running in 19b69d089ff2
config-set expects 2 or 3 parameters
Since it is a RUN
command, you can add a test:
docker build -t my_apache . --build-arg http_proxy=....
With a Dockerfile:
ARG http_proxy
RUN if [ "x$http_proxy" != "x" ] ; then pear config-set http_proxy $http_proxy; fi
You actually don't need the ARG http_proxy
as it is one of the predefined ones.