IT.en_US/Cloud_container_kube

Docker Commands: A Beginner's Guide

동구멍폴로 2023. 2. 8. 00:22
반응형

Docker Commands: A Beginner's Guide

Docker is a platform for developing, deploying, and running applications using containers. Containers provide a way to package an application and all its dependencies into a single, self-contained unit that can be easily deployed and run on any system. One of the key benefits of Docker is that it makes it simple and easy to manage containers and their associated resources. This article will introduce you to the most commonly used Docker commands, so you can get started using Docker right away.

Docker Command Line Interface (CLI)

Docker provides a command-line interface (CLI) that you can use to interact with the Docker engine and manage containers. The Docker CLI is the primary tool for interacting with Docker, and it provides a simple and straightforward way to perform common tasks, such as starting and stopping containers, managing images, and managing networks.

Common Docker Commands

Here are some of the most commonly used Docker commands:

Docker run

The docker run command is used to start a new container from an image. You can use the docker run command to start a container and run an application inside of it. For example:

docker run --name my-container -d my-image

This command starts a new container named my-container from the image my-image in the background (-d flag).

Docker ps

The docker ps command is used to list the containers that are currently running on your system. For example:

docker ps

This command lists all the containers that are currently running on your system, along with their status, names, and IDs.

Docker stop

The docker stop command is used to stop a running container. For example:

docker stop my-container

This command stops the container named my-container.

Docker rm

The docker rm command is used to remove a container. For example:

docker rm my-container

This command removes the container named my-container.

Docker images

The docker images command is used to list the images that are currently stored on your system. For example:

docker images

This command lists all the images that are currently stored on your system, along with their names, IDs, and sizes.

Docker pull

The docker pull command is used to download an image from a Docker registry, such as Docker Hub. For example:

docker pull my-image

This command downloads the image named my-image from Docker Hub.

Docker push

The docker push command is used to upload an image to a Docker registry, such as Docker Hub. For example:

docker push my-image

This command uploads the image named my-image to Docker Hub.

Advanced Docker Commands

In addition to the common Docker commands listed above, there are many other Docker commands that you can use to manage containers and their associated resources. Some of the most commonly used advanced Docker commands include:

  • docker inspect: used to inspect the properties of a container or image
  • docker logs: used to view the logs generated by a container
  • docker network: used to manage networks and the connections
반응형