Docker: Docker main commands

Docker is a powerful platform for developing, shipping, and running applications inside containers. Here are some of the main Docker commands that you’ll frequently use:

1. Docker Version:

  • Check the installed Docker version.

docker --version

2. Docker Help:

  • Get help and see a list of Docker commands and their descriptions.

docker --help

3. Docker Images:

  • List all locally available Docker images.

docker images

4. Docker Pull:

  • Download a Docker image from a registry (e.g., Docker Hub).

docker pull image_name:tag

5. Docker Run:

  • Create and start a new container from an image.

docker run [options] image_name [command]

6. Docker PS:

  • List running containers.

docker ps

7. Docker PS (All Containers):

  • List all containers, including stopped ones.

docker ps -a

8. Docker Stop:

  • Stop a running container gracefully.

docker stop container_id_or_name

9. Docker Kill:

  • Forcefully stop a running container.

docker kill container_id_or_name

10. Docker Start:

  • Start a stopped container.

docker start container_id_or_name

11. Docker Remove:

  • Remove a stopped container.

docker rm container_id_or_name

12. Docker Logs:

  • View the logs of a container.

docker logs container_id_or_name

13. Docker Exec:

  • Run a command inside a running container.

docker exec [options] container_id_or_name command

14. Docker Network:

  • List and manage Docker networks.

docker network ls

15. Docker Volume:

  • List and manage Docker volumes.

docker volume ls

16. Docker Build:

  • Build a Docker image from a Dockerfile.

docker build -t image_name:tag path_to_Dockerfile_directory

17. Docker Compose:

  • Manage multi-container Docker applications using a Compose file.

docker-compose [options] command

18. Docker Save and Load:

  • Save an image as a tarball and load it from a tarball.

docker save -o image_name.tar image_name:tag docker load -i image_name.tar

19. Docker Push:

  • Push a locally built image to a Docker registry.

docker push image_name:tag

20. Docker Search:

  • Search for Docker images on Docker Hub.

docker search search_term

These are some of the essential Docker commands to get you started. Docker provides many more commands and options for more advanced use cases and customization. You can always refer to the official Docker documentation or use the docker --help command to explore more options and details for each command.