Module 05 · Final Assignment
Cheatsheet: Introduction to Containers with Docker, Kubernetes and OpenShift速查表:Docker、Kubernetes 和 OpenShift 的容器介绍
Estimated time: 40 minutes
预计时间:40 分钟
Docker CLI Docker 命令行界面
| Command 命令 | Description 描述 |
|---|---|
curl localhost |
Pings the application. 轻点应用。 |
| docker build | Builds a Docker image from a specified Dockerfile. 从指定的 Dockerfile 构建 Docker 镜像。 |
| docker build . -t | Builds the image and tags the image id. 构建镜像并标记镜像 ID。 |
| docker CLI | Starts the Docker Command Line Interface (CLI). 启动 Docker 命令行界面(CLI)。 |
| docker container rm | Removes a container. 删除一个容器。 |
| docker images | Displays a list of all available Docker images. 显示所有可用的 Docker 镜像列表。 |
| docker ps | Lists the containers. 列出容器。 |
| docker ps -a | Lists the containers that ran and exited successfully. 列出成功运行并退出的容器。 |
| docker pull | Pulls the latest image or repository from a registry. 从注册表中拉取最新的镜像或仓库。 |
| docker push | Pushes an image or a repository to a registry. 将镜像或仓库推送到注册表。 |
| docker run | Runs a command in a new container. 在一个新容器中运行命令。 |
| docker run -p | Runs the container by publishing the ports. 通过发布端口来运行容器。 |
| docker stop | Stops one or more running containers. 停止一个或多个正在运行的容器。 |
| docker stop $(docker ps -q) | Stops all currently running containers. 停止所有当前正在运行的容器。 |
| docker tag | Creates a tag for a target image that refers to a source image. 为目标图像创建一个指向源图像的标签。 |
docker --version |
Displays the version of the Docker CLI. 显示 Docker CLI 的版本。 |
| exit | Closes the terminal session. 关闭终端会话。 |
| export MY_NAMESPACE | Exports a namespace as an environment variable. 将命名空间导出为环境变量。 |
| git clone | Clones the git repository that contains the artifacts needed. 克隆包含所需工件的 git 仓库。 |
| ibmcloud cr images | Lists images in the IBM Cloud Container Registry. 列出 IBM 云容器注册表中的镜像。 |
| ibmcloud cr login | Logs your local Docker daemon into IBM Cloud Container Registry. 将本地 Docker 守护进程登录到 IBM Cloud 容器注册中心。 |
| ibmcloud cr namespaces | Displays the namespaces available to the current user in the IBM Cloud Container Registry. 显示当前用户在 IBM Cloud 容器注册中心可用的命名空间。 |
| ibmcloud cr region-set | Ensures that you are targeting the region appropriate to your cloud account. 确保您正在针对与您的云帐户适当的区域。 |
| ibmcloud target | Provides information about the account you're targeting. 提供有关您正在针对的帐户的信息。 |
| ibmcloud version | Displays the current version of the IBM Cloud CLI. 显示 IBM Cloud CLI 的当前版本。 |
| ls | Lists the files and directories in the current directory. 列出当前目录中的文件和目录。 |
Understanding Kubernetes Architecture
理解 Kubernetes 架构
| Command 命令 | Description 描述 |
|---|---|
| for …do | Runs a sequence of commands multiple times as specified. 按照指定次数多次执行一系列命令。 |
| kubectl apply | Applies a specified configuration to a resource. 将指定配置应用于资源。 |
| kubectl config get-clusters | Displays all clusters defined in the kubeconfig. 显示 kubeconfig 中定义的所有集群。 |
| kubectl config get-contexts | Displays the current context. 显示当前上下文。 |
| kubectl create | Creates a new Kubernetes resource based on a given specification. 根据给定规范创建一个新的 Kubernetes 资源。 |
| kubectl delete | Deletes resources. 删除资源。 |
| kubectl describe | Provides details of a resource or group of resources. 提供资源或一组资源的详细信息。 |
| kubectl expose | Exposes a resource to the internet as a Kubernetes service. 将资源作为 Kubernetes 服务暴露到互联网上。 |
| kubectl get | Displays resources. 显示资源。 |
| kubectl get pods | Lists all the Pods. 列出所有 Pod。 |
| kubectl get pods -o wide | Lists all the Pods with details. 列出所有 Pod 及其详细信息。 |
| kubectl get deployments | Displays all deployments created. 显示所有已创建的部署。 |
| kubectl get services | Lists the services created. 列出了创建的服务。 |
| kubectl proxy | Creates a proxy server between a localhost and the Kubernetes API server.在本地主机和 Kubernetes API 服务器之间创建一个代理服务器。 |
| kubectl run | Creates and runs a particular image in a pod. 在一个 Pod 中创建并运行特定的图像。 |
| kubectl version | Prints the client and server version information. 打印客户端和服务器版本信息。 |
Managing Applications with Kubernetes
使用 Kubernetes 管理应用程序
| Command 命令 | Description 描述 |
|---|---|
| kubectl autoscale deployment | Autoscales a Kubernetes Deployment. 自动扩展 Kubernetes Deployment。 |
| kubectl create configmap | Creates a ConfigMap resource. 创建 ConfigMap 资源。 |
| kubectl get deployments -o wide | Lists deployments with details. 列出具有详细信息的部署。 |
| kubectl get hpa | Lists Horizontal Pod Autoscalers (hpa). 列出水平 Pod 自动缩放器(hpa)。 |
| kubectl scale deployment | Scales a deployment. 对部署进行缩放。 |
| kubectl set image deployment | Updates the current deployment. 更新当前部署。 |
| kubectl rollout | Manages the rollout of a resource. 管理资源的部署。 |
| kubectl rollout restart | Restarts the resource so that the containers restart. 重启资源,以便容器重启。 |
| kubectl rollout undo | Rollbacks the resource. 回滚资源。 |
OpenShift CLI
| Command 命令 | Description 描述 |
|---|---|
| oc get | Displays a resource. 显示资源。 |
| oc project | Switches to a different project. 切换到不同的项目。 |
| oc version | Displays version information. 显示版本信息。 |