Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

Modify way of how use local image as base image #27

Closed
marc- opened this issue Mar 10, 2015 · 8 comments
Closed

Modify way of how use local image as base image #27

marc- opened this issue Mar 10, 2015 · 8 comments

Comments

@marc-
Copy link
Contributor

marc- commented Mar 10, 2015

I was trying to run sequentially creation of two images following way:

require "chef/provisioning/docker_driver"
with_driver "docker"
machine_image "machine1" do
  recipe "my_recipe::1"
  machine_options :docker_options => {
      :base_image => {
          :name => "ubuntu",
          :repository => "ubuntu",
          :tag => "14.04"
      }
  }
end

machine_image "machine2" do
  recipe "my_recipe::2"

  machine_options :docker_options => {
      :base_image => {
          :name => "chef",
          :repository => "chef",
          :tag => "machine1"
       }
  }
end

But it doesn't work for some reason. Still looking on it.

marc- added a commit to marc-/chef-provisioning-docker that referenced this issue Mar 12, 2015
@marc-
Copy link
Contributor Author

marc- commented Mar 12, 2015

There is actually :from_image docker option. Unfortunately it doesn't allow to preserve initial image repository name and tag. It is also skips convergence phase.

@marc- marc- changed the title No way to use local image as base image in machine_image Modify way of how use local image as base image Mar 20, 2015
@jkeiser
Copy link
Contributor

jkeiser commented Apr 27, 2015

@marc- you should be able to do this:

require "chef/provisioning/docker_driver"
with_driver "docker"
machine_image "machine1" do
  recipe "my_recipe::1"
  machine_options :docker_options => {
      :base_image => {
          :name => "ubuntu",
          :repository => "ubuntu",
          :tag => "14.04"
      }
  }
end

machine_image "machine2" do
  recipe "my_recipe::2"
  from_image 'machine1'
end

@marc-
Copy link
Contributor Author

marc- commented Apr 27, 2015

This will work for this particular case. But what if you need to run machine from local image, which wasn't created with machine_image and is not available in remote registry, for instance built from Dockerfile?

marc- added a commit to marc-/chef-provisioning-docker that referenced this issue May 24, 2015
marc- added a commit to marc-/chef-provisioning-docker that referenced this issue May 29, 2015
Signed-off-by: Maksim Chizhov <maksim.chizhov@gmail.com>
randomcamel pushed a commit that referenced this issue Jun 4, 2015
Signed-off-by: Maksim Chizhov <maksim.chizhov@gmail.com>
@marc-
Copy link
Contributor Author

marc- commented Jun 4, 2015

Modifying my example to make it more clear:

require "chef/provisioning/docker_driver"
with_driver "docker"

machine_image "machine" do
  recipe "my_cookbook::some_recipe"

  machine_options :docker_options => {
      :base_image => {
          :name => "image_built_from_dockerfile",
          :repository => "image_built_from_dockerfile",
          :tag => "latest"
       }
  }
end

@tyler-ball
Copy link
Contributor

I'm just getting up to speed with all this, so I may be wrong. But my initial analysis is that we should support base images from an existing docker image in a remote repository, or a local repository (from a Dockerfile) or another machine_image resource. I think its confusing to have two different ways to specify a base image - 1) via the from_image attribute or 2) from the :base_image hash in the :docker_options.

Because from_image is a base machine_options attribute can we update it to support all the desired behaviors? We could have it accept a string like name:repository:tag (because it only accepts a String now and not a Hash). First, we try to find a resource named name:repository:tag. If we cannot find that, look for an image using the :name, :repository and :tag parsed out from the String.

If we want to keep them separate, I think we should get much better documentation about the difference between the from_image attribute (can only reference other resources) and the :base_image hash in the machine_options attribute (references either a local or remote Docker repo).

\cc @jkeiser

@marc-
Copy link
Contributor Author

marc- commented Jun 8, 2015

Not sure if it's good idea to put docker specific options into chef-provisioning specific context.
Also, talking about refactoring and confusion, as there any justification for :name base image option?

randomcamel pushed a commit that referenced this issue Jun 8, 2015
Signed-off-by: Maksim Chizhov <maksim.chizhov@gmail.com>
@randomcamel
Copy link
Contributor

The original issue should be fixed by PR #47. @tyler-ball go ahead and close, or leave open for discussion, as desired.

@randomcamel
Copy link
Contributor

Reading more carefully I see that Tyler asked me to close it, so. 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants