Detailed explanation of Docker basics and common commands.

Docker is a containerization platform for packaging, distributing and running applications. It allows developers to easily deploy applications in different environments, providing isolation and portability. The following is a detailed explanation of some basic concepts and common commands of Docker:

Basic concept:

  1. Image: A Docker image is a read-only template used to create a Docker container. It contains all the files, dependencies and configuration information needed to run the application.
  2. Container: A Docker container is a running instance created based on a Docker image. Containers are executable, can be started, stopped, deleted, and can communicate with other containers or the host.
  3. Warehouse (Repository): The Docker warehouse is a place for storing and sharing Docker images. It can be a public repository, like Docker Hub, or a private repository.

Common commands:

  1. Mirror related commands:

    • docker images: List all local Docker images.
    • docker pull <镜像名>: Download the specified Docker image from the repository.
    • docker build -t <镜像名> <Dockerfile路径>: Build the image according to the Dockerfile.
    • docker rmi <镜像名>: Delete the specified Docker image.
  2. Container related commands:

    • docker ps: List running containers.
    • docker run <镜像名>: Create and start a new container.
    • docker start <容器ID或名称>: Start the created container.
    • docker stop <容器ID或名称>: Stops the running container.
    • docker rm <容器ID或名称>: Delete the specified container.
  3. Repository related commands:

    • docker search <关键字>: Search for images on Docker Hub.
    • docker push <镜像名>: Push the image to the specified warehouse.
    • docker pull <仓库名>/<镜像名>: Download the image from the specified repository.
  4. Other common commands:

    • docker exec -it <容器ID或名称> <命令>: Executes a command in a running container.
    • docker logs <容器ID或名称>: View the logs of the container.
    • docker inspect <容器ID或名称>: Get the details of the container.
    • docker-compose up: Start the application using Docker Compose.

This is just a brief introduction to some basics and common commands of Docker. Docker has more features and options to explore, you can refer to the official Docker documentation for more detailed information and to learn about other commands. Remember, with hands-on and practice, you'll get a better handle on Docker and increase your originality rate.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/131269612