I'm trying to install composer on docker container. I have a container laravel55
and I'm gonna to install composer insite it.
docker exec laravel55 curl --silent --show-error
https://getcomposer.org/installer | php
#result
Composer (version 1.6.5) successfully installed to: /root/docker-
images/docker-php7-apache2/composer.phar
Use it: php composer.phar
Aftar installation, I'm trying to using composer
but it doesn't work:
docker exec -w /var/www/html laravel55 php composer.phar install
#result
Could not open input file: composer.phar
It seems that Composer had not installed! How can I install composer on a docker container?
Well with your command you're actually installing composer.phar locally on your host, you just execute the curl command inside the container. The part behind the pipe symbol |
is not executed in your docker container but on your host. In your second command you switch your working directory to /var/www/html
where you apparently expect the composer.phar
but not in the first command.
So to make the whole command run in the container, you can try the following:
docker-compose exec -w /var/www/html laravel55 \
sh -c "curl --silent --show-error https://getcomposer.org/installer | php"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments