Docker is an open-source platform that enables developers to build, ship, and run applications in containers. Containers are lightweight, standalone, and executable packages that include everything an application needs to run, such as code, libraries, and dependencies.
Key Features:
- Containerization: Package applications and their dependencies into a single container.
- Lightweight: Containers are much lighter than virtual machines.
- Portable: Containers run consistently across different environments.
- Isolated: Containers run in isolation, ensuring application security.
Benefits:
- Faster Deployment: Quickly deploy applications without worrying about dependencies.
- Efficient Resource Usage: Optimize resource usage with containerization.
- Improved Collaboration: Ensure consistency across development, testing, and production environments.
Essential Docker Commands
Get the list of active docker containers:
docker ps -a
Get the list of all docker containers:
docker ps
Log into the docker container:
docker exec -it <container-id> /bin/bash
Stop the docker container:
docker stop <container-id>
Remove the docker container:
docker rm <container-id>
Remove the docker image:
docker rmi <docker-image-id>
Check the logs of the docker container:
docker logs <container-id>
Get continuous log output of the docker container:
docker logs -f <container-id>
OR
docker logs --follow <container-id>
Tail last 100 lines of logs of the docker container:
docker logs --tail 100 <container-id>