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.

  • Platform to test with docker containers in developer environment
  • How can I achieve installing a application like Jenkins into a running CentOs container running inside a CentOs image using chef-recipe?
  • Smooth solution for using docker with chef
  • How to manage deployment?
  • Octohost with knife solo on bare metal? (UserError: Vagrant not installed)
  • Chef Test Kitchen - Verifications
  • 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.

  • Slow network in Docker container after OpenShift install
  • Jelastic run.log not working on docker
  • Kubernetes minion not completely connecting
  • can't pull docker images from nexus proxy
  • Customize Docker reverse DNS
  • How is Vagrant an advantage over boot2docker? [closed]
  • 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.