-
Notifications
You must be signed in to change notification settings - Fork 83
Luojh -- improve docker #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Deploying linux101-docs with
|
Latest commit: |
9987097
|
Status: | ✅ Deploy successful! |
Preview URL: | https://ca33a9e9.linux101-docs.pages.dev |
Branch Preview URL: | https://luojh-improve-docker.linux101-docs.pages.dev |
@@ -303,7 +323,7 @@ Docker 在根据 Dockerfile 构建时,会从上到下执行这些指令,每 | |||
RUN yum clean all | |||
``` | |||
|
|||
当然,这不等于说必须要把所有命令都写在一条 `RUN` 里面。对于执行时间很长的命令,可以考虑放在 Dockerfile 的开头,并且使用单独的 `RUN` 运行,因为 Docker 在构建镜像时,可以重复使用之前构建好的层。这么做可以节约构建与调试 Dockerfile 的时间。 | |||
当然,这不等于说必须要把所有命令都写在一条 `RUN` 里面。对于执行时间很长的命令,可以考虑放在 Dockerfile 的开头,并且使用单独的 `RUN` 运行,因为 Docker 在构建镜像时,*可以重复使用之前构建好的层*。这么做可以节约构建与调试 Dockerfile 的时间。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中文没有斜体,改成加粗或者下划线。
@@ -246,7 +266,7 @@ CMD ["fish"] | |||
sudo docker build -t riscv-cross:example . | |||
``` | |||
|
|||
`-t riscv-cross:example` 代表为这个镜像打上 `riscv-cross:example` 的标签。构建完成后,使用 `docker run` 执行即可: | |||
`-t riscv-cross:example` 代表为这个镜像打上 `riscv-cross:example` 的标签,`.` 表示从当前目录下寻找 Docker 并以当前目录作为构建过程的“工作路径”。构建完成后,使用 `docker run` 执行即可: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`-t riscv-cross:example` 代表为这个镜像打上 `riscv-cross:example` 的标签,`.` 表示从当前目录下寻找 Docker 并以当前目录作为构建过程的“工作路径”。构建完成后,使用 `docker run` 执行即可: | |
`-t riscv-cross:example` 代表为这个镜像打上 `riscv-cross:example` 的标签,`.` 表示从当前目录下寻找 Dockerfile 并以当前目录作为构建过程的“工作路径”。构建完成后,使用 `docker run` 执行即可: |
|
||
这里,`--rm` 代表容器停止运行(退出)之后,会被立刻删除;`--name` 参数代表给容器命名,如果没有加这个参数,那么 docker 会给容器随机起一个格式类似于 gracious_brahmagupta 的名字。 | ||
|
||
`-it` 是为了获得可交互的 Shell 所必须的。`-i` 会将容器的 init(主进程,这里是 `/bin/bash`)的标准输入与 `docker` 这个程序的标准输入相连接;而 `-t` 会告知主进程输入为终端(TTY)设备。 | ||
|
||
在执行以上命令之后,你会获得一个 Ubuntu 20.04 的容器环境,退出 Shell 之后容器就会被销毁。 | ||
在执行以上命令之后,你会获得一个 Ubuntu(版本为 Latest 的;如果需要指定版本,可以使用类似 `20.04` 的版本号替换 `latest`,这在生产环境中是非常建议的,因为 `latest` 指定最新版本而可能随时间变化)的容器环境,退出 Shell 之后容器就会被销毁。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在执行以上命令之后,你会获得一个 Ubuntu(版本为 Latest 的;如果需要指定版本,可以使用类似 `20.04` 的版本号替换 `latest`,这在生产环境中是非常建议的,因为 `latest` 指定最新版本而可能随时间变化)的容器环境,退出 Shell 之后容器就会被销毁。 | |
在执行以上命令之后,你会获得一个 Ubuntu(版本为最新的 LTS;如果需要指定版本,可以使用类似 `20.04` 的版本号替换 `latest`,这在生产环境中是非常建议的,因为 `latest` 指定最新版本而可能随时间变化)的容器环境,退出 Shell 之后容器就会被销毁。 |
@@ -16,7 +16,7 @@ icon: simple/docker | |||
|
|||
Docker 能够利用 Linux 内核的容器特性,隔离出一个轻便的环境来运行程序。这有什么意义呢?试想以下这些情况: | |||
|
|||
- 你运行的 Linux 发行版很老,而你需要运行一个更新版本的 Linux 发行版,或者完全不同的 Linux 发行版设计的程序。 | |||
- 你运行的 Linux 发行版很老,而你需要运行一个更新版本的 Linux 发行版,或者完全不同的 Linux 发行版设计的程序(但注意:它们都是 Linux)。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要强调的是?感觉 Linux 这个词在不同的语境下就在指代不同的东西。可能可以这样:
- 你运行的 Linux 发行版很老,而你需要运行一个更新版本的 Linux 发行版,或者完全不同的 Linux 发行版设计的程序(但注意:它们都是 Linux)。 | |
- 你运行的 Linux 发行版很老,而你需要运行一个更新版本的 Linux 发行版,或者完全不同的 Linux 发行版设计的程序(但注意:它们都共用同一个 Linux 内核)。 |
No description provided.