Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the entire Build API through REST and introspection #8032

Closed
thedrow opened this issue Sep 15, 2014 · 6 comments
Closed

Expose the entire Build API through REST and introspection #8032

thedrow opened this issue Sep 15, 2014 · 6 comments
Labels
area/builder kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny

Comments

@thedrow
Copy link

thedrow commented Sep 15, 2014

Currently it is only possible to build a docker image from a tarball containing a Dockerfile using the REST API.
There's no reason why we shouldn't be able to build a docker image entirely using the REST API.
This will enable integrations with multiple configuration management tools like Salt and Puppet which already have superior and less error prone provisioning capeabilities.
How hard would it be to achieve this?
It would involve exposing all commands in https://github.com/docker/docker/blob/master/builder/dispatchers.go if I understand correctly.

@tiborvass
Copy link
Contributor

IMHO what would be even better, is to expose the build api to containers via daemon introspection. That way you could write shell scripts inside containers and salt and puppet would just have to call dockerfile commands. It's a different (and more difficult?) approach but I find it more powerful, since it would finally enable docker build to be a full-fledged docker run, and the Dockerfile/Dockerscript to behave as anyone would expect. WDYT?

@thedrow
Copy link
Author

thedrow commented Sep 15, 2014

That will also work but it strikes me as more complex.
Why is it more powerful?
How would you provision a container with docker-py using that method for example? Eventually Salt will use it to provision containers. Puppet and Chef will use the ruby client and so on.
The REST API provides a convenient way to communicate with docker using any client or just an HTTP client (e.g. cURL).
How would the remote API look like with the method you proposed?

@thedrow
Copy link
Author

thedrow commented Sep 23, 2014

@tiborvass ping?

@tiborvass
Copy link
Contributor

@thedrow Don't get me wrong, I'm not necessarily opposed to an API for build as you described, I just wanted to point to daemon introspection as a possible solution.

I agree it seems a bit complex, but for me the major benefit is that it would be "jailbreaking" the buildtime: right now certain things are allowed in docker run (volumes, editing /etc/hosts, etc.) that are not possible with docker build. But when you think about it, building is nothing more than just running a container as specified by a Dockerfile and a context and saving the resulting image. Except, that you don't have all the expressiveness of docker run.

An equivalent solution today would be to do docker run --rm -v /bind:/mount myimage-builder | docker build -t myimage - where myimage-builder would stream the tar context to stdout.

If there were daemon introspection, you could imagine a sortof docker commit inside the container that would build the layers one after the other. Be it manual, or (more useful) scripted. There are a lot of things that need to be discussed (UI for introspection etc.) but how I currently imagine building a container: docker build -v /bind:/mount -t myimage where the Dockerfile could be some sort of Docker script or maybe even ANY script (shell, python, ruby, ...) that simply calls dockerfile commands. For instance:

$ dockerscript from ubuntu
$ dockerscript run echo hello from dockerscript

Keep in mind that it's far from clear for me what would be the best UI.

3rd parties could simply call a docker build API similar to the one we have today, and put their customizations in the Dockerscript (that would have a shebang):

$ cat Dockerscript
#!/bin/sh
dockerscript from ubuntu
text="hello from dockerscript"
dockerscript run echo $text

# there could be optimizations like accepting multiple commands across multiple lines:
dockerscript <<EOF
run echo foo
run echo bar
EOF

Sorry if you feel I'm hijacking your issue. We can talk more on IRC (handle: tibor).

@thedrow thedrow changed the title Expose the entire Build API through REST Expose the entire Build API through REST and introspection Sep 23, 2014
@jessfraz jessfraz added kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny area/builder labels Feb 25, 2015
@thedrow
Copy link
Author

thedrow commented Jul 19, 2015

Any updates on this one?
I know that we have docker exec but that only helps us not having to run the provisioner inside the container which is not enough. I'd like to fully utilize the build caching mechanism that docker provides us with.

@tiborvass
Copy link
Contributor

I'm closing this since #13171 was merged which was the last blocker for implementing #14298.

@jlhawn implemented an experimental client-side builder: https://github.com/jlhawn/dockramp which uses the new APIs in #13171.

Hope this helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/builder kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny
Projects
None yet
Development

No branches or pull requests

3 participants