Images vs Containers
- Docker Image: blueprint with app code and dependencies - static, read-only
- Docker Container: running instance of an image - dynamic, executable
Each instruction in the Dockerfile adds an extra layer to the Docker image. Minimize the number of layers by consolidating the instructions to increase the build’s performance and time.
Avoid using multiple RUN commands as it creates multiple cacheable layers which will affect the efficiency of the build process.
Use a single process per container: Each container should run a single process. This makes it easier to manage and monitor containers and helps to keep containers lightweight.
Images can exist without containers, whereas a container needs an image to run. We can create multiple containers from the same image, each with its own unique data and state
Docker commands
- Docker Run: It used for launching the containers from images, with specifying the runtime options and commands.
- Docker Pull: It fetches the container images from the container registry like Docker Hub to the local machine.
- Docker ps: It helps in displaying the running containers along with their important information like container ID, image used and status.
- Docker Stop: It helps in halting the running containers gracefully shutting down the processes within them.
- Docker Start: It helps in restarting the stopped containers, resuming their operations from the previous state.
- Docker Login: It helps to login in to the docker registry enabling the access to private repositories.
Docker network commands:
- docker network ls
- docker network inspect
Documentation
- Dockerfile reference - examples
- Dockerfile overview - with example
- Command Line Completion
- Base images - includes building from scratch
- CLI Cheat Sheet
- tutorial


