Docker Containers

Manipulating

Renaming a Container

docker rename my-nginx my-nginx

Removing a Container

docker rm my-nginx

Updating a Container

docker update --cpu-shares 512 -m 300M my-nginx

Creating

docker create [options] IMAGE
  -a, --attach               # attach stdout/err
  -i, --interactive          # attach stdin (interactive)
  -t, --tty                  # pseudo-tty
      --name NAME            # name your image
  -p, --publish 5000:5000    # port map (host:container)
      --expose 5432          # expose a port to containers
  -P, --publish-all          # publish all ports
      --link container:alias # linking
  -v, --volume `pwd`:/app    # mount (absolute paths needed)
  -e, --env NAME=hello       # env vars

#Example

$ docker create --name my\_redis --expose 6379 redis:3.0.2

Information

Example Description
docker ps List running containers
docker ps -a List all containers
docker logs my-nginx Container Logs
docker inspect my-nginx Inspecting Containers
docker events my-nginx Containers Events
docker port my-nginx Public Ports
docker top my-nginx Running Processes
docker stats my-nginx Container Resource Usage
docker diff my-nginx Lists the changes made to a container.

Starting & Stopping

Description Example
docker start my-nginx Starting
docker stop my-nginx Stopping
docker restart my-nginx Restarting
docker pause my-nginx Pausing
docker unpause my-nginx Unpausing
docker wait my-nginx Blocking a Container
docker kill my-nginx Sending a SIGKILL
docker attach my-nginx Connecting to an Existing Container
Comments