Auto-sync: 2026-04-17 08:35
This commit is contained in:
45
wiki/concepts/Dockerfile.md
Normal file
45
wiki/concepts/Dockerfile.md
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
title: Dockerfile
|
||||
type: concept
|
||||
tags: [docker, build, image]
|
||||
last_updated: 2026-04-17
|
||||
---
|
||||
|
||||
## Definition
|
||||
Dockerfile 是用于构建 Docker 镜像的声明式配置文件,包含基础镜像选择、文件复制、命令执行等步骤。
|
||||
|
||||
## 基本语法
|
||||
|
||||
```dockerfile
|
||||
FROM <base_image>
|
||||
USER root
|
||||
RUN <command>
|
||||
USER <non_root_user>
|
||||
```
|
||||
|
||||
## Common Instructions
|
||||
- FROM:指定基础镜像
|
||||
- RUN:执行命令
|
||||
- COPY:复制文件
|
||||
- WORKDIR:设置工作目录
|
||||
- USER:切换用户
|
||||
- ENV:设置环境变量
|
||||
- EXPOSE:声明端口
|
||||
- CMD:容器启动命令
|
||||
|
||||
## Example
|
||||
|
||||
```dockerfile
|
||||
FROM n8nio/n8n:latest
|
||||
USER root
|
||||
RUN apk update && apk add --no-cache curl wget
|
||||
USER node
|
||||
```
|
||||
|
||||
## Related Concepts
|
||||
- [[Docker]]
|
||||
- [[Docker-Image]]
|
||||
- [[Docker-Compose]]
|
||||
|
||||
## Related Entities
|
||||
- [[n8n]]
|
||||
Reference in New Issue
Block a user