【问题标题】:Kitchen-Docker specify image name for DockerfileKitchen-Docker 为 Dockerfile 指定镜像名称
【发布时间】:2018-11-18 02:11:54
【问题描述】:

我目前正在使用kitchen-docker 驱动程序来测试我的食谱。想知道如何为kitchen create 命令构建的图像指定图像名称:标签。

这是我的 .kitchen.yml :

---
driver:
  name: docker
  use_sudo: false
  dockerfile: ../Dockerfile
  remove_images: true
  privileged: true
  run_command: /usr/sbin/init

provisioner:
  name: chef_zero
  data_bags_path: 'data_bags'
  environments_path: 'environments'
  cookbook_path: "cookbooks"
  client_rb:
    environment: development

platforms:
  - name: centos-7
    driver_config:
      container_name: myapp
      instance_name: myapp


suites:
  - name: default
    run_list:
      - recipe[web_server::default]
      - recipe[app_server::default]
    attributes:

运行命令:

kitchen create

创建一个 docker 镜像为<none> 我想调用这个镜像为mycompany/app

REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
<none>                             <none>              18e663ff7508        17 seconds ago      1.14GB

非常感谢任何帮助。

【问题讨论】:

    标签: docker chef-infra test-kitchen


    【解决方案1】:

    对此没有选择,kitchen-docker 不使用标签,因为它不需要它们,它会跟踪构建映像 ID 本身。

    【讨论】:

      【解决方案2】:

      其实我找到了办法。

      您实际上可以通过build_options: 和tag。如下代码所示。

      .kitchen.yml(完整的 yml 文件在上面的问题中。)

      platforms:
       - name: centos-7
         driver_config:
          dockerfile: ../Dockerfile
          build_options:
           tag: mycompany/myapp:latest
           rm: true
          container_name: myapp
          instance_name: myapp
      

      【讨论】:

        猜你喜欢
        • 2016-11-22
        • 2014-11-12
        • 1970-01-01
        • 1970-01-01
        • 2016-12-23
        • 1970-01-01
        • 2020-04-29
        • 1970-01-01
        • 2016-01-13
        相关资源
        最近更新 更多