notes/docker

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.

But save yourself some keystrokes and add the following to your profile script.

# PowerShell
function d {
    docker run --rm -itv ${pwd}:/app $args
}

Composer

# Everything automatically is run as a composer command
d composer $cmd
# EG Run composer install
d 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
d gsingh1/prestissimo install

PHP

CLI

d php:alpine $cmd
# EG Run PHPUnit
d php:alpine sh -c "cd app ; php vendor/bin/phpunit"

NodeJS

# EG Run npm install
d node:alpine sh -c "cd /app ; npm install"