Technology Encyclopedia Home >What are the common commands for Containerd and Docker components?

What are the common commands for Containerd and Docker components?

Containerd and Docker are both containerization technologies, but they have different command-line interfaces (CLI) for managing containers and related components. Here are some common commands for each:

Containerd Commands

Containerd is a container runtime that focuses on the lifecycle management of containers.

  • ctr: The primary CLI for interacting with containerd.
    • ctr containers list: Lists all containers.
    • ctr images list: Lists all images.
    • ctr run --rm docker.io/library/nginx:latest my-nginx: Runs a container and removes it after stopping.
    • ctr snapshot ls: Lists all snapshots (root filesystems).

Docker Commands

Docker is a more comprehensive platform that includes a CLI for managing containers, images, networks, and volumes.

  • docker: The primary CLI for interacting with Docker.
    • docker ps: Lists all running containers.
    • docker images: Lists all images.
    • docker run -d --name my-nginx nginx: Runs a container in detached mode and names it.
    • docker stop my-nginx: Stops a running container.
    • docker rm my-nginx: Removes a stopped container.
    • docker rmi nginx: Removes an image.
    • docker network ls: Lists all networks.
    • docker volume ls: Lists all volumes.

Example Usage

  • Containerd:

    ctr images pull docker.io/library/nginx:latest
    ctr run --rm docker.io/library/nginx:latest my-nginx
    
  • Docker:

    docker pull nginx
    docker run -d --name my-nginx nginx
    

Cloud Service Recommendation

For managing containers in the cloud, Tencent Cloud offers TKE (Tencent Kubernetes Engine), which simplifies the deployment, scaling, and management of containerized applications. TKE integrates with containerd and Docker to provide a robust container management solution.

By using TKE, you can leverage the power of Kubernetes to orchestrate your containers, ensuring high availability, scalability, and efficient resource utilization.