Skip to content

Latest commit

 

History

History
116 lines (74 loc) · 4.66 KB

gentoo_image.rst

File metadata and controls

116 lines (74 loc) · 4.66 KB

Gentoo镜像

DockerHub Gentoo 提供了 gentoo_linux 官方镜像:

Gentoo使用 openrc 提供了轻量级的 openrc-init 可以在Docker容器中作为 docker_init

基础运行 gentoo-base

fedora_tini_image 类似,我们需要一个轻量级的的 docker_init 。显然采用 systemd 对于容器过于沉重,而且容器通常是直接运行程序,无需独立的 docker_init 。只不过,为了适应我们的开发环境,我们构建一个通过 init 来运行多个程序的富容器。

Gentoo 默认的 openrc 是一个轻量级的解决方案,不仅被Gentoo作为默认进程管理器,也是轻量级发行版 alpine_linux 默认进程管理器。这个 sys-apps/openr 已经默认在官方镜像中提供,只不过一般不会启用(因为容器都是轻量级的单个应用运行),常规的容器最后执行命令就是直接应用程序,例如 /bin/bash 或者 /usr/sbin/nginx

非常幸运的是 openrc 和Docker兼容性极佳,可以轻而易举在Docker中采用:

gentoo_image/base/Dockerfile

  • 构建 gentoo-base 镜像:

gentoo_image/base/build_gentoo-base_image

  • 运行 gentoo-base 镜像:

gentoo_image/base/run_gentoo-base_container

  • 连接到 gentoo-base 容器内:

gentoo_image/base/exec_gentoo-base_container

基础运行 gentoo-base-plus

在上述最为简单的 Gentoo 基础上,按照 gentoo_on_gentoo 的实践定制一个包含工具、本地化等配置的镜像,并启用 ssh 服务:

gentoo_image/base-plus/Dockerfile

  • 构建 gentoo-base-plus 镜像:

gentoo_image/base-plus/build_gentoo-base-plus_image

  • 运行 gentoo-base-plus 镜像:

gentoo_image/base-plus/run_gentoo-base-plus_container

  • 连接到 gentoo-base-plus 容器内:

gentoo_image/base-plus/exec_gentoo-base-plus_container

开发环境 gentoo-dev

Note

开发环境的构建 Dockerfile 将随着我的开发学习以及工作不断调整和完善

  • gentoo-base-plus 增加开发工具安装的 Dockerfile (逐步完善):

gentoo_image/dev/Dockerfile

Note

墙内使用 rvm 需要梯子,所以结合 docker_proxysquid_socks_peer 实现翻墙。上面的 Dockerfile 配置中通过添加环境变量使得容器镜像构建时可以使用代理服务器。

如果没有GFW干扰,可以去除代理配置;请按照实际情况调整配置内容

  • 构建 gentoo-dev 镜像:

gentoo_image/dev/build_gentoo-dev_image

  • 运行 gentoo-dev 镜像:

gentoo_image/dev/run_gentoo-dev_container

  • 连接到 gentoo-dev 容器内:

gentoo_image/dev/exec_gentoo-dev_container

参考