Handy Docker Commands

I love Docker. Being able to spin up a project with infrastructure of varying degrees of complexity without messing up your local environment in the process is awesome. That said the more useful commands can become a challenge to recall, so I’ve compiled this list of handy docker commands.

As time goes on I’ll add to the list. If you find the list helpful and would like to make an addition, just reach out to me via the contacts on the site.


# Everything automatically is run as a composer command
docker run --rm -it --volume ${pwd}:/app composer $cmd
# EG Run composer install
docker run --rm -it --volume ${pwd}:/app composer install

# Expedite installs and updates by using composer with the prestissimo plugin
# Fingers crossed that the improvements it brings will make it into v2
docker run --rm -it --volume ${pwd}:/app gsingh1/prestissimo install



docker run --rm -it --volume ${pwd}:/app php $cmd
# EG Run PHPUnit
docker run --rm -it --volume ${pwd}:/app php bash -c "cd app ; php vendor/bin/phpunit"


# EG Run npm install
docker run --rm -it --volume ${pwd}:/app node sh -c "cd /app ; npm install"