-
Understanding Images v/s Containers
-
Running Ubuntu Image in Container
-
Multiple Containers
-
Port Mappings
-
Environment Variables
-
Dockerization of Node.js Application
-
Dockerfile
-
Caching Layers
-
Publishing to Hub
-
-
Docker Compose
-
Services
-
Port Mapping
-
Env Variables
-
-
Docker Networking
-
Bridge
-
Host
-
-
Volume Mounting
-
Efficient Caching in Layers
-
Docker Multi-Stage Builds
-
List all active containers:
docker container ls -
List all active and inactive containers:
docker container -a -
Start a container:
docker start container_name -
Stop a container:
docker stop container_name -
List directories inside a container and exit:
docker exec container_name ls -
Access a container's shell interactively (without exiting):
docker exec -it container_name bash -
List all locally available Docker images:
docker imagesordocker image ls -
Run a Docker container interactively, expose a specific port, and set environment variables:
docker run -it -p 1025:1025 -e key=val mailhog/mailhog -
Build a Docker image from a specified directory and assign a name:
docker build -t image_name directory_pathExample:
docker build -t my_app .
-
Log in to your Docker Hub (or other registry) account:
docker login -
Create and start containers
docker compose up <--attach or --detach >&docker compose down
-
Docker Networking
-
Host : uses Host machines network
docker run -it --name my_container --network=Host Image_Name -
Bridge : Establish Bridge between Host machine and docker
docker run -it --name my_container --network=Bridge Image_Name -
none : No internet
docker run -it --name my_container --network=none Image_Name
-
-
Create Custom Docker Network
docker network create -d bridge mynet- containers which uses same network can communicate with each other
-
use
docker network lsto List down all available networks, -
use
docker network inspect <network_name>to see which cotainers are using the same network.
-
to Create volume :
docker run -it -v <host_file_path>:<container_file_path>for example :
docker run -it -v /Users/HP/Desktop/test-folder:/home/test ubuntu