ПІДТРИМАЙ УКРАЇНУ ПІДТРИМАТИ АРМІЮ
Uk Uk

Docker Cheat Sheet all You Need To Know About Docker Command

Docker Cheat Sheet all You Need To Know About Docker Command

Docker is a platform that allows developers to create, deploy, and run applications in a...

Docker is a platform that allows developers to create, deploy, and run applications in a containerized environment. A container is a lightweight, standalone, and executable software package that includes everything needed to run a piece of software, including the code, runtime, system tools, libraries, and settings.

Docker enables developers to package their applications and dependencies into a container, which can be easily moved between different environments, such as development, test, and production. This allows developers to ensure that their applications will run consistently across different environments, regardless of the underlying infrastructure.

Docker also provides a centralized repository called Docker Hub, where developers can store and share their container images. This allows other developers to easily download and use these images in their own applications, which can save time and effort in the development process.

Docker provides a command-line interface (CLI) that allows developers to interact with the Docker daemon, which is the process that manages the containers on a machine. Some of the commonly used Docker commands include:

  • docker version: This command displays the version of Docker that is currently installed on the machine.
  • docker pull: This command is used to download an image from Docker Hub or a private repository. The syntax for this command is docker pull , for example docker pull python. You can also specify a specific version of an image by appending the version number to the image name, for example, docker pull python:3.10-buster.
  • docker ps: This command is used to list all running containers on a machine. You can use option -a also to see containers that have been stopped.
  • docker run: This command is used to create a new container from an image. The syntax for this command is docker run , for example, docker run Redis. You can also specify additional options when running a container, such as -d to run the container in detached mode, -p to map a host port to a container port, --name to give the container a specific name, and --volume to mount a host directory as a volume in the container.
  • docker start, docker stop, docker restart: these commands are used to start, stop, and restart a container.
  • docker rm: This command is used to remove a container.
  • docker images: this command is used to list all the images that are currently on your machine.
  • docker logs: This command is used to view the logs of a running container. By default, it shows the logs of the latest container created, but you can specify a container name or ID to view the logs of a specific container.
  • docker exec: This command is used to run a command inside a running container. For example, docker exec -it /bin/bash would open a bash shell inside the specified container.
  • docker inspect: This command is used to view detailed information about a container or image, such as its configuration, network settings, and mounted volumes.
  • docker network: This command is used to manage Docker networks, which allow containers to communicate with each other. You can use sub-commands such as create, ls, inspect, and rm to create, list, inspect and remove networks respectively.
  • docker volume: This command is used to manage Docker volumes, which allow data to persist outside of a container's filesystem. You can use sub-commands such as create, ls, inspect, and rm to create, list, inspect and remove volumes respectively.
  • docker system prune: This command is used to remove unused data, such as stopped containers and unused images, from the host machine.
  • docker build: This command is used to build a container image from a Dockerfile. A Dockerfile is a script that contains instructions for building an image.
  • docker tag : This command allows you to assign a specific version or tag to an image. This can be useful when you want to deploy a specific version of your image to production.
  • docker push: This command is used to push an image to a registry, such as Docker Hub, so that others can download it.

These are just a few examples of the many commands that are available in Docker. It's important to note that these commands can also have additional options and parameters that can be used to customize their behavior. The official Docker documentation is a great resource for learning more

Ресурс : dev.to


Scroll to Top