Search code examples
dockerchef-infratest-kitchen

Kitchen-Docker specify image name for Dockerfile


I am currently using kitchen-docker driver for testing my cookbooks. Wondering how to specify a image name:tag for the image that is build by the kitchen create command.

Here is my .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:

Run the command:

kitchen create

Creates a docker image as <none> I would like to call the image as mycompany/app

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

any help is massively appreciated.


Solution

  • Actually I found a way to do it.

    you can actually pass the build_options: and tag. As shown in the code below.

    .kitchen.yml (the full yml file is in the question above.)

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