# Start the docker daemondocker-d# Get help with Docker. Can also use –help on all subcommandsdocker--help# Display system-wide informationdockerinfo
Images
Docker images are a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings
# Build an Image from a Dockerfile
docker build -t <image_name>
# Build an Image from a Dockerfile without the cache
docker build -t <image_name> . –no-cache
# List local images
docker images
# Delete an Image
docker rmi <image_name>
# Remove all unused images
docker image prune
Docker Hub
Docker Hub is a service provided by Docker for finding and sharing container images with your team. Learn more and find images at https://hub.docker.com
# Login into Dockerdockerlogin-u<username># Publish an image to Docker Hubdockerpush<username>/<image_name># Search Hub for an imagedockersearch<image_name># Pull an image from a Docker Hubdockerpull<image_name>
Containers
A container is a runtime instance of a docker image. A container will always run the same, regardless of the infrastructure. Containers isolate software from its environment and ensure that it works uniformly despite differences for instance between development and staging.
# Create and run a container from an image, with a custom name:dockerrun--name<container_name><image_name># Run a container with and publish a container’s port(s) to the host.dockerrun-p<host_port>:<container_port><image_name># Run a container in the backgrounddockerrun-d<image_name># Start or stop an existing container:dockerstart|stop<container_name> (or <container-id>)# Remove a stopped container:dockerrm<container_name># Open a shell inside a running container:dockerexec-it<container_name>sh# Fetch and follow the logs of a container:dockerlogs-f<container_name># To inspect a running container:dockerinspect<container_name> (or <container_id>)# To list currently running containers:dockerps# List all docker containers (running and stopped):dockerps--all# View resource usage statsdockercontainerstats