Skip to content

Latest commit

 

History

History
93 lines (81 loc) · 6.92 KB

File metadata and controls

93 lines (81 loc) · 6.92 KB

Few helpful docker commands

Example commands

  • docker system prune clears dangling images, exited containers and unused layers
  • docker volume prune clears the unused volumes
  • docker network prune
  • docker container prune
  • docker image prune clears all unused images

Example commands 2

docker ps -a shows running and stopped containers. docker stats --all shows a list of all containers, default shows just running.

# Get the server version
docker version --format '{{.Server.Version}}'

Load an image from file:

docker load < my_image.tar.gz

Save an existing image:

docker save my_image:my_tag | gzip > my_image.tar.gz

Attaching resources

CPU:

docker run -it -c 512 agileek/cpuset-test

Memory

docker run -it -m 300M ubuntu:14.04 /bin/bash

Dockerfile

  • .dockerignore
  • FROM Sets the Base Image for subsequent instructions.
  • MAINTAINER (deprecated - use LABEL instead) Set the Author field of the generated images.
  • RUN execute any commands in a new layer on top of the current image and commit the results.
  • CMD provide defaults for an executing container.
  • EXPOSE informs Docker that the container listens on the specified network ports at runtime. NOTE: does not actually make ports accessible.
  • ENV sets environment variable.
  • ADD copies new files, directories or remote file to container. Invalidates caches. Avoid ADD and use COPY instead.
  • COPY copies new files or directories to container. By default this copies as root regardless of the USER/WORKDIR settings. Use --chown=<user>:<group> to give ownership to another user/group. (Same for ADD.)
  • ENTRYPOINT configures a container that will run as an executable.
  • VOLUME creates a mount point for externally mounted volumes or other containers.
  • USER sets the user name for following RUN / CMD / ENTRYPOINT commands.
  • WORKDIR sets the working directory.
  • ARG defines a build-time variable.
  • ONBUILD adds a trigger instruction when the image is used as the base for another build.
  • STOPSIGNAL sets the system call signal that will be sent to the container to exit.
  • LABEL apply key/value metadata to your images, containers, or daemons.