Table of contents
Docker Concepts:
Images: Read-only templates used to create Docker containers.
Containers: Running instances of Docker images.
Dockerfile: A text file that contains instructions to build a Docker image.
Docker Registry: A centralized repository for storing and sharing Docker images (e.g., Docker Hub).
Commands for Installing Docker
Installing docker on Ubuntu machine-
Basic Docker Commands
Image Management:
docker images
: List all available Docker images.docker pull <image_name>
: Download an image from a registry.docker build -t <image_name> <path_to_dockerfile>
: Build an image using a Dockerfile.docker rmi <image_name>
: Remove an image.
Container Management:
docker run <image_name>
: Create and start a new container from an image.docker ps
: List running containers.docker ps -a
: List all containers (including stopped ones).docker start <container_id>
: Start a stopped container.docker stop <container_id>
: Stop a running container.docker rm <container_id>
: Remove a container.
Interacting with Containers:
docker exec -it <container_id> <command>
: Run a command inside a running container.docker cp <container_id>:<container_path> <host_path>
: Copy files between a container and the host.
Networking:
docker network ls
: List Docker networks.docker network create <network_name>
: Create a new Docker network.docker network connect <network_name> <container_id>
: Connect a container to a network.
Volumes:
docker volume ls
: List Docker volumes.docker volume create <volume_name>
: Create a new Docker volume.docker run -v <volume_name>:<container_path> <image_name>
: Mount a volume in a container.
Docker Compose:
docker-compose up
: Create and start containers defined in a Compose file.docker-compose down
: Stop and remove containers defined in a Compose file.
Miscellaneous:
docker logs <container_id>
: View the logs of a container.docker inspect <container_id>
: Get detailed information about a container.
Thanks for Reading!