Commands
8 methods用于容器和镜像生命周期的顶层 docker 子命令。
FROM image[:tag] [AS stage]从镜像创建新容器并启动,运行给定命令。
Parameters
| Name | Type | Description |
|---|---|---|
| image | string | Base image name. |
| tag | string | Image tag (defaults to latest). |
| stage | string | Optional name for a multi-stage build stage. |
Returns
void
Example
docker
FROM node:18-alpine AS builderRUN <command> | RUN ["exec", "arg1", ...]从给定路径或 URL 中的 Dockerfile 构建镜像。
Parameters
| Name | Type | Description |
|---|---|---|
| command | string | Shell command (shell form) or JSON array (exec form). |
Returns
void
Example
docker
RUN apt-get update && apt-get install -y curl gitCOPY [--chown=user:group] src... dest从注册表下载镜像并本地存储。
Parameters
| Name | Type | Description |
|---|---|---|
| src | string | string[] | Source path(s) in the build context. |
| dest | string | Absolute or relative destination inside the container. |
| --chown | string | Optional user:group ownership for the copied files. |
Returns
void
Example
docker