## 编写 Dockerfile 文件
```js
FROM scratch
ADD alpine-minirootfs-3.15.0-x86_64.tar.gz /
CMD ["/bin/sh"]
```
## 创建基本的系统
下载 alpine-minirootfs
网址:https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/
当前的最新版本(2022-1-15:3.15)
https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-minirootfs-3.15.0-x86_64.tar.gz
把下载的文件系统压缩包放在与 Dockerfile 同目录中。
### 执行命令:
```sh
sudo docker build -t alpine:3.15 .
```
结果:
```sh
Sending build context to Docker daemon 2.734MB
Step 1/3 : FROM scratch
—>
Step 2/3 : ADD alpine-minirootfs-3.15.0-x86_64.tar.gz /
—> 05d50e706b9e
Step 3/3 : CMD ["/bin/sh"]
—> Running in 2af0abf293ac
Removing intermediate container 2af0abf293ac
—> 1ba2af961c9b
Successfully built 1ba2af961c9b
Successfully tagged alpine:3.15
```
### 运行
```sh
sudo docker run -i -t alpine:3.15 /bin/sh
```
交互:
```sh
kaW:~/dockerNew$ sudo docker run -i -t alpine:3.15 /bin/sh
/ # ls
bin etc lib mnt proc run srv tmp var
dev home media opt root sbin sys usr
/ # uname -a
Linux 34a76607b27d 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 Linux
/ #
```
原文链接:https://blog.csdn.net/wide288/article/details/122518501?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165934458816781647589803%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165934458816781647589803&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-21-122518501-null-null.nonecase&utm_term=%E8%87%AA%E5%BB%BAcdn
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/7379