Docker Frequently Used Commands

Sat Jun 11, 2016

Next: Refer to my powerpoint deck for Docker

Next: compare docker-compose to Ansible Container - not sure what advantages Ansible may have over docker-compose?


Docker Frequently Used Commands

This is a list of frequently used docker commands

Docker Containers

docker run --rm -ti -d -e DISPLAY=x.x.x.x:0 -v /path/to/mount:/mount/point/in/container -p hostPort:containerPort imageID

docker run --rm -ti -p 1313:1313 -v $(pwd):/srv/hugo hugo sh

docker ps -a

To drop out of interactive session on container: <ctrl-p><ctrl-q>
NOTE: this does not seem to work with Docker Beta for Mac on "docker run", but does work for "docker exec"

docker stop containerID
docker start  containerID

NOTE: may need to remove 'attach' from this list 

docker attach containerID

docker exec -ti containerID /bin/bash

docker logs containerID

$ docker help logs

Usage:	docker logs [OPTIONS] CONTAINER

Fetch the logs of a container

  -f, --follow        Follow log output
  --help              Print usage
  --since             Show logs since timestamp
  -t, --timestamps    Show timestamps
  --tail=all          Number of lines to show from the end of the logs

docker rm containerID

Docker images

docker images
docker rmi imageID

docker build -t containerName .  
(assumes that valid `Dockerfile` exists in the current directory)

Docker Registry

docker login

docker pull

docker push

Docker Compose

docker-compose up 

docker-compose ps 

docker-compose stop

docker-compose start

docker-compose rm -f