📜  docker cli (1)

📅  最后修改于: 2023-12-03 14:40:48.849000             🧑  作者: Mango

Docker CLI

Docker Command Line Interface (CLI) is a powerful tool that allows developers and system administrators to interact with Docker containers and manage various aspects of container-based applications. In this guide, we will discuss the most commonly used Docker CLI commands and their functionalities.

Docker CLI Installation

To use Docker CLI, you should first install Docker on your machine. Docker is available for Windows, macOS, and Linux operating systems. Please follow the official Docker installation guide for your specific operating system.

Basic Docker CLI Commands
1. Docker Version

To check the version of Docker installed on your system, use the following command:

docker version

This command provides information about the Docker Engine, Client, and other details related to the installation.

2. Docker Image Management

Docker images are the building blocks of containers. You can use the following commands to manage Docker images:

  • Pull: To download Docker images from a registry (e.g., Docker Hub), use the pull command:

    docker pull image_name[:tag]
    
  • List: To list all the downloaded Docker images on your system, use the images command:

    docker images
    
  • Remove: To delete a Docker image from your local system, use the rmi command:

    docker rmi image_name[:tag]
    
3. Docker Container Management

Docker containers are isolated execution environments created from Docker images. The following commands help manage Docker containers:

  • Run: To create and start a new container from a Docker image, use the run command:

    docker run [options] image_name[:tag]
    
  • List: To view all active running containers, use the ps command:

    docker ps
    
  • Stop: To stop a running container, use the stop command:

    docker stop container_id
    
  • Remove: To delete a stopped container, use the rm command:

    docker rm container_id
    
4. Docker Compose

Docker Compose is a tool that allows defining and running multi-container Docker applications. You can use the following command to manage Compose-based applications:

  • Up: To create and start containers for services defined in the docker-compose.yml file, use the up command:

    docker-compose up [options]
    
Conclusion

Docker CLI provides a comprehensive set of commands to manage Docker images, containers, and Compose-based applications. With these commands, developers can easily work with containers and build powerful, scalable applications using Docker. Explore the Docker documentation for more advanced features and commands.

Markdown code blocks are denoted by triple backticks (`).