📜  interface docker - Shell-Bash (1)

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

Interface Docker - Shell-Bash

Docker is a platform for developers to build, ship, and run applications as containers. Containers are lightweight, portable, and self-contained packages that are an excellent way to manage your applications' dependencies.

With the Docker CLI, developers can interact with the Docker daemon, which is responsible for building, shipping, and running Docker containers. The Docker CLI is a command-line interface that allows developers to interact with the Docker daemon through shell scripts.

In this tutorial, we will cover the essential commands you need to know to interact with Docker containers using the Shell-Bash interface.

Prerequisites

Before we begin, you should have the Docker CLI installed on your system. You can download and install it from the official Docker website.

Docker Commands

Here are some of the essential Docker commands you need to know:

docker version

This command displays the Docker version installed on your system, along with the version of the Docker CLI and Docker daemon.

$ docker version
Client: Docker Engine - Community
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.16.3
 Git commit:        370c289
 Built:             Fri Apr  9 22:46:31 2021
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:44:56 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc95
  GitCommit:        b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
docker pull

This command pulls a Docker image from a registry. A registry is a storage system for Docker images. The most popular Docker registry is Docker Hub.

$ docker pull ubuntu
docker run

This command runs a Docker container from an image.

$ docker run ubuntu:latest

This command will start a new container from the Ubuntu image and run the latest version.

docker ps

This command lists all the running Docker containers on your system.

$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
docker stop

This command stops a running Docker container.

$ docker stop container-name
docker rm

This command removes a Docker container.

$ docker rm container-name
Conclusion

With the commands we covered in this tutorial, you can manage your Docker containers using the Shell-Bash interface. Containers are an excellent way to manage your applications' dependencies and ensure that they run consistently across different environments. If you're new to Docker, we encourage you to learn more about it as it can significantly improve your development workflow.