3.10. 通过自定义 Dockerfile 修改容器镜像
要获得最大的灵活性,您可以指定一个包含 Dockerfile 的目录进行所需更改。调用 tripleo-modify-image 角色时,该角色生成 Dockerfile.modified 文件,而该文件更改 FROM 指令并添加额外的 LABEL 指令。以下示例在 nova-compute 镜像上运行自定义 Dockerfile:
ContainerImagePrepare:
- push_destination: true
...
includes:
- nova-compute
modify_role: tripleo-modify-image
modify_append_tag: "-hotfix"
modify_vars:
tasks_from: modify_image.yml
modify_dir_path: /home/stack/nova-custom
...
例如 /home/stack/nova-custom/Dockerfile。运行任何 USER 根指令后,必须切换回原始镜像默认用户:
FROM registry.redhat.io/rhosp15-rhel8/openstack-nova-compute:latest
USER "root"
COPY customize.sh /tmp/
RUN /tmp/customize.sh
USER "nova"