# Docker CLI Cheat Sheet
# Images
## Build an Image from a Dockerfile
```sh
docker build -t <image_name> .
docker build -t <image_name> . –-no-cache
docker images
docker rmi <image_name>
docker image prune
docker login -u <username>
docker push <username>/<image_name>
docker search <image_name>
docker pull <image_name>
docker run --name <container_name> <image_name>
docker run -p <host_port>:<container_port> <image_name>
docker run -d <image_name>
docker start|stop <container_name> (or <container-id>)
docker rm <container_name>
docker exec -it <container_name> sh
docker logs -f <container_name>
docker inspect <container_name> (or <container_id>)
docker ps
docker ps --all
docker container stats
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.
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.
docker -d
docker --help
docker info