docker cheat sheet

-

Introduction

The key benefit of Docker is that it allows users to package an application with all of its dependencies into a standardized unit for software development.

Check Version

  • docker version

Containers

Lifecycle

  • docker create - creates a container but does not start it.
  • docker rename - allows the container to be renamed.
  • docker run - creates and starts a container in one operation.
    • -t - allocate a pseudo-TTY session
    • -d - run container in background and print container ID
    • --rm - will remove the container after it stops.
    • -v - map a directory on the host to a docker container.docker run -v $HOSTDIR:$DOCKERDIR
    • --name
  • docker rm - deletes a container.
    • -v - remove the volumes associated with the container
  • docker update - updates a container’s resource limits.

Starting and Stopping

  • docker start - starts a container so it is running.
  • docker stop - stops a running container.
  • docker restart - stops and starts a container.
  • docker pause - pauses a running container, “freezing” it in place.
  • docker unpause - will unpause a running container.
  • docker wait - blocks until running container stops.
  • docker kill - sends a SIGKILL to a running container.
  • docker attach - will connect to a running container.

Info

  • docker ps - shows running containers.
    • -a - shows running and stopped containers.
  • docker logs - gets logs from container. (You can use a custom log driver, but logs is only available for json-file and journald in 1.10).
  • docker inspect - looks at all the info on a container (including IP address).
  • docker events - gets events from container.
  • docker port - shows public facing port of container.
  • docker top - shows running processes in container.
  • docker stats - shows containers’ resource usage statistics.
  • docker diff - shows changed files in the container’s FS.

Import / Export

  • docker cp - copies files or folders between a container and the local filesystem.
  • docker export - turns container filesystem into tarball archive stream to STDOUT.

Executing Commands

  • docker exec - execute a command in container.docker exec -it foo /bin/bash

CPU Constraints

Memory Constraints

Capabilities


Images

Lifecycle

  • docker images - shows all images.
  • docker import - creates an image from a tarball.
  • docker build - creates image from Dockerfile.
  • docker commit - creates image from a container, pausing it temporarily if it is running.
  • docker rmi - removes an image.
  • docker load - loads an image from a tar archive as STDIN, including images and tags (as of 0.7).
  • docker save - saves an image to a tar archive stream to STDOUT with all parent layers, tags & versions (as of 0.7).

Info

  • docker history - shows history of image.
  • docker tag - tags an image to a name (local or registry).

error

error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.35/version: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
1
net start com.docker.service

  docker
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×