Docker 88 - Learning Notes
# 啊
The Docker daemon runs the instructions in the Dockerfile one-by-one, committing the result of each instruction to a new image if necessary, before finally outputting the ID of your new image. The Docker daemon will automatically clean up the context you sent.
Note that each instruction is run independently, and causes a new image to be created - so RUN cd /tmp will not have any effect on the next instructions.
Whenever possible, Docker uses a build-cache to accelerate the docker build process significantly. This is indicated by the CACHED message in the console output. (For more information, see the Dockerfile best practices guide)
# Hello World (TBD)
FROM .
# ...
docker build .
<build & execution result here>
# 基本用法
# build
docker build
命令通过执行 Dockerfile 中的指令来构建 Docker 镜像,并以指定的本地路径 PATH
或 Git 仓库 URL
作为构建的上下文。
docker build [OPTIONS] PATH | URL | -
在大多数情况下,最好将构建上下文保持干净,仅在其中保存 Dockerfile 和构建所需的文件。
通过 -t
选项指定保存新镜像的 仓库 (repository) 和 标记 (tag) ,可以通过多个 -t
选项指定保存多份副本到不同的仓库和标记:
docker build -t shykes/myapp .
# run
As an example, let’s run a container using the latest image of Ubuntu. The combination of the -i and -t switches gives you interactive shell access into the container:
docker run -it ubuntu
# 镜像管理
docker images
docker ps
# 指令
Dockerfile 指令的基本格式如下:
# Comment
INSTRUCTION arguments
事实上指令名称 INSTRUCTION
不区分大小写,但是我们约定使用大写,以将其与参数 arguments
区分开来。
# 注释
# 环境变量
https://docs.docker.com/engine/reference/builder/#environment-replacement
# 卷
https://docs.docker.com/storage/volumes/
https://techblog.geekyants.com/understanding-docker-volumes-1
- 01
- Reading Papers - Kernel Concurrency06-01
- 02
- Linux Kernel - Source Code Overview05-01
- 03
- Linux Kernel - Per-CPU Storage05-01