Show Menu

Docker OSX use Cheat Sheet by

Useful commands for our team on OS X

docker­-ma­chine (Work with Virtual Machine)

create --driver driverName newMac­hin­eName
Create docker machine
create --driver virtualbox --virt­ual­box­-memory 2048 memcrab
Create docker machine "­mem­cra­b" on virtualBox with 2048 mb RAM
start machin­eName
start virtualbox docker machine
stop machin­eName
stop docker machine
restart machin­eName
restart docker machine
rm machin­eName
remove docker machine. WARNING: will remove all contai­ners, images and cache
env machin­eName
show current IP and all info
eval "­$(d­ock­er-­machine env machin­eNa­me)­"
Link terminal TAB to use current Docker machine on "­doc­ker­" and "­doc­ker­-co­mpo­se" commands. Can be added to .bash_­profile

docker­-co­mpose (Use stack of Contai­ner­s/I­mages)

Build or rebuild all docker images from docker­-co­mpo­se.yml file
build nodejs
Build only one selected docker iage from docker­-co­mpo­se.yml file
Run containers from all docker images
up nodejs
Run containers from selected docker image
Stop all composed containers
stop nodejs
Stop selected composed container

docker (Use single Contai­ner­/Image)

run -it --rm imageName runCom­man­dName
Run new container from image and delete it after finish command
exec -it contai­nerName runCom­man­dName
Execute some command on already running container and exit
exec -it contai­nerName /bin/bash
Connect to already running container with terminal access
Show running containers
ps -a
Show all containers
stop contai­nerName
Stop container
start contai­nerName
Start stopped container
rm contai­nerName
Remove stopped container

Some quick hacks

docker rmi $(docker images -f "­dan­gli­ng=­tru­e" -q)
Remove all unusable builds­/images - free space on your hard drive
docker volume rm $(docker volume ls -qf dangli­ng=­true)
Remove all unusable shared volumes - free space on your hard drive

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          docker-compose Cheat Sheet
          Docker Cheat Sheet