Dynamically Pull Docker Image using chef recipe

What Chef-Recipe should do-

1- Install Docker service.
2- Dynamically Pull Docker Image; Count depends on User request.
3- Dynamically Run Docker Containers; Count depends on User request.

  • How to preserve apt-cache archive directory when using docker / host volumes
  • Installing docker containers via chef with staged files
  • chef-container + chef-vault
  • Chef Test Kitchen verify file exists inside Docker container
  • AWS opswork docker: Missing Cookbooks:No such cookbook: docker
  • Octohost with knife solo on bare metal? (UserError: Vagrant not installed)
  • What below Chef-recipe is doing-

    1- Install Docker service.
    2- Pull Docker Image;
    3- Run Docker Containers;

    Chef-docker recipe-

    #
    # Cookbook Name:: chef-docker
    # Recipe:: default
    #
    # Copyright 2016, SONATA_SOFTWARE
    #
    # All rights reserved - Do Not Redistribute
    #
    docker_service 'default' do
      action [:create, :start]
    end
    # Pull latest image
    docker_image 'centos' do
      tag 'latest'
      action :pull
    end
    # Run container 
    docker_container 'first' do
      repo 'centos'
      command '/bin/bash'
      tty true
      action :run
      end  
      docker_container 'second' do
      repo 'centos'
      command '/bin/bash'
      tty true
      action :run
      end
    

    I am clueless on how to call/pull “n” no# of image and “n” no# of container dynamically or from outside recipe on user request. Any insight on this will help me.

  • Using docker during build of Dockerfile
  • Docker compose install requirements in a shared directory
  • API server failed to start up
  • Not able to bind to docker container port
  • Does anyone know a docker image that contains The MySQL Test Framework, Version 2.0?
  • Build the Node js app on Docker
  • One Solution collect form web for “Dynamically Pull Docker Image using chef recipe”

    Well you would use a data_bag for that, and then look over the data_bag items like “containers and pull / start per containers.

    Look at this very good example in the docs https://docs.chef.io/data_bags.html#create-users

    In their case they loop over a data_bag which defines users, and then create those one by on.

    So a user request is an entry in the data_bag for that particular node

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.