Dockerizing Composer

Paul Seiffert
1 min readNov 2, 2014

This article is part of a series in which I describe how I dockerize my development environment. So far, I’ve published the following articles:

Composer

Composer is the package manager for PHP libraries. When working in PHP projects, you cannot (and should not) live without it. You use it to add a new library to your project, for creating new projects, and also for updating libraries you already use.

In most projects I’ve worked in, the execution of the actual PHP code happens in a virtual environment (usually a virtual machine running on VirtualBox and being managed with Vagrant). There are however situations in which it is either not possible to use a virtual machine or it has not been created yet (because you’re in the process of bootstrapping a new project).

In these cases, it might be handy to just run composer on your computer. If you don’t want to maintain a PHP installation on your system, you can use the following alias to run composer inside a Docker container.

alias composer='docker run --rm -it -v $(pwd):/opt pseiffert/composer'

For a detailed description of the parameters —rm, -it, and -b, see my previous article about Dockerizing NPM.

--

--