Docker container to install and run Composer.
- Composer
master
: Latest snapshotlatest
: Latest stable release1
: Latest1.*
stable release1.0
: Latest1.0.*
stable release1.0.1
1.0.0
1.0.0-beta2
1.0.0-beta1
1.0.0-alpha11
1.0.0-alpha10
1.0.0-alpha9
1.0.0-alpha8
- PHP 7
-
Install the
composer/composer
container:$ docker pull composer/composer
Alternatively, pull a specific version of composer/composer
:
sh $ docker pull composer/composer:1.0.1
-
Create a composer.json defining your dependencies. Note that this example is a short version for applications that are not meant to be published as packages themselves. To create libraries/packages please read the documentation.
{ "require": { "monolog/monolog": ">=1.0.0" } }
-
Run Composer through the Composer container:
$ docker run --rm -v $(pwd):/app composer/composer install
Or run using a specific version of Composer:
sh $ docker run --rm -v $(pwd):/app composer/composer:1.0.1 install
If working with packages installed via git ssh the local .ssh directory shall be mapped into the container:
sh $ docker run --rm -v $(pwd):/app -v ~/.ssh:/root/.ssh composer/composer install
- Add optional
composer
command to the host (tested on OS X El Capitan with docker-machine)
Create new composer file
sh $ sudo vim /usr/local/bin/composer
The contents of the file will look like this:
sh #!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin echo "Current working directory: '"$(pwd)"'" docker run --rm -v $(pwd):/app -v ~/.ssh:/root/.ssh composer/composer $@
Once the script has been made, it must be set as executable
sh $ sudo chmod +x /usr/local/bin/composer
Now the composer
command is available native on host:
sh $ composer --version
Name | Description |
---|---|
/app |
The working directory for the application. |
To run, test and develop the Composer Dockerfile itself, you must use the source directly:
-
Download the source:
$ git clone https://github.com/RobLoach/composer-docker.git
-
Switch to the
composer-docker
directory:$ cd composer-docker
-
Build the base container (in case of adaptions on the composer base image only)
$ docker build -t composer/composer:base base
-
Build the container, using Composer's latest
master
release:$ docker build -t composer/composer:latest master
-
Test running Composer through the container:
$ docker run composer/composer help