opensour.cc developers' network - quick start guides to bootstrap examples

(Perfect for people with a short attention span, needing to get work done!)

Most issues can be resolved with the following sets of commands. For more advanced issues, please check out the troubleshooting and tips-and-tricks pages.

Containers

List

  • Running containers
    • docker ps
  • All containers, regardless of run-status
    • docker ps --all
  • All exited containers
    • docker ps --all --quiet --filter 'status=exited'
  • Latest created container
    • docker ps --latest
  • n last created containers (using -n=1 is equivalent to the preceding --latest suffix)
    • docker ps -n=#

Access

  • Container running in the background
    • docker attach <containerIdOrName>
  • Bash Shell of a container running in the background
    • docker run --interactive --tty <containerIdOrName> bash
  • Stopped container and jumping straight into a Bash Shell
    • docker run --interactive --tty --entrypoint /bin/bash <containerIdOrName>
  • If Bash isn't installed, other options to try are: 1)
    • docker exec --interactive --tty <containerIdOrName> /bin/sh
    • docker export <containerIdOrName> | tar -t | egrep ^bin/

Remove

  • All stopped containers
    • docker rm $(docker ps --all --quiet --no-trunc --filter 'status=exited')
  • All containers 2)
    • docker rm $(docker ps --all --quiet --no-trunc)
  • Containers created after a specific container
    • docker rm $(docker ps --quiet --since <containerIdOrName>)
  • Containers created before a specific container
    • docker rm $(docker ps --quiet --before <containerIdOrName>)

Images

List

  • Images
    • docker images
  • All images, including intermediate layers
    • docker images --all
  • Dangling/untagged images
    • docker images --filter 'dangling=true'

Remove

  • All images
    • docker rmi $(docker images --quiet --all)
  • Dangling/untagged images
    • docker rmi $(docker images --quiet --filter 'dangling=true')

Volumes

FIXME

Inspect

docker inspect <containerIdOrName> provides information about varying aspects of a container; and can be used for something as banal yet important as the container's IP Address, to listing all port bindings.

Network

  • Instance's IP address
    • docker inspect --format='{{.NetworkSettings.IPAddress}}' <containerIdOrName>
  • Instance's MAC Address
    • docker inspect --format='{{.NetworkSettings.MacAddress}}' <containerIdOrName>
  • List all port bindings
    • docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' <containerIdOrName>
  • List specific port mapping
    • docker inspect --format='{{(index (index .NetworkSettings.Ports "<PortNumber>/tcp") 0).HostPort}}' <containerIdOrName>

Configuration

  • Instance's log path
    • docker inspect --format='{{.LogPath}}' <containerIdOrName>
  • Instance's config
    • docker inspect --format='{{json .config}}' <containerIdOrName>
Navigation
Print/export