Skip to content

The repository contains a collection of tutorials and guides that will help you get started with Docker, as well as a variety of small Docker projects that you can use as templates for your own projects.

Notifications You must be signed in to change notification settings

farasatkhan/Dockerization

Repository files navigation

Dockerization

The repository contains a collection of tutorials and guides that will help you get started with Docker, as well as a variety of small Docker projects that you can use as templates for your own projects.

Docker Installation

sudo apt install -y docker.io

Docker Compose Installation

curl -SL https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

docker-compose --version

Docker Cheat Sheet

Images

Builds a Docker image with the specified name and a Dockerfile in the current directory.

docker build -t <image_name>

Builds a Docker image with the specified name and a Dockerfile in the current directory, ignoring the cache.

docker build -t <image_name> . –no-cache

Lists all Docker images that are currently stored on the host.

docker images

Lists all Docker images that are currently stored on the host.

docker image ls

Removes the specified Docker image from the host.

docker rmi <image_name>

Removes all unused Docker images, including intermediate images, from the host.

docker image prune

Docker Hub

Logs in to a Docker registry with the specified username.

docker login -u <username>

Pushes a Docker image with the specified name to a registry with the specified username.

docker push <username>/<image_name>

Searches for a Docker image with the specified name in Docker Hub or other registries.

docker search <image_name>

Downloads a Docker image with the specified name from a registry.

docker pull <image_name>

Containers

Runs a Docker container with the specified name and image.

docker run --name <container_name> <image_name>

Runs a Docker container with the specified image and maps the host port to the container port.

docker run -p <host_port>:<container_port> <image_name>

Runs a Docker container with the specified image in detached mode.

docker run -d <image_name>

Starts or stops a running Docker container with the specified name.

docker start|stop <container_name>

Removes the specified Docker container from the host.

docker rm <container_name>

Executes a command in a running Docker container with the specified name and opens a terminal.

docker exec -it <container_name> sh

Displays the logs of a running Docker container with the specified name in real-time.

docker logs -f <container_name>

Displays detailed information about a Docker container with the specified name.

docker inspect <container_name>

Lists all running Docker containers on the host.

docker ps

Lists all Docker containers that are currently stored on the host.

docker ps --all

Displays resource usage statistics of all running Docker containers on the host.

docker container stats

Docker Compose

Runs the Docker Compose in detached mode.

sudo docker-compose up -d

Displays the status of containers in the Docker Compose.

sudo docker-compose ps

Stops and removes the containers, networks, and volumes defined in the Docker Compose.

sudo docker-compose down

About

The repository contains a collection of tutorials and guides that will help you get started with Docker, as well as a variety of small Docker projects that you can use as templates for your own projects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published