I want to integrate my Go code with Docker which is also in Go. I want to do something like:
myapp.Run()
IMG := dockerapi.Pull("namespace/my image")
IMG.Run()
What do you recommend if I want to run docker commands in the middle of my Go program program flow.
Thanks!
Docker offers a rest based API for interacting with it programatically:
Example request:
POST /images/create?fromImage=base HTTP/1.1
Example response:
HTTP/1.1 200 OK
Content-Type: application/json
{"status":"Pulling..."}
{"status":"Pulling", "progress":"1 B/ 100 B", "progressDetail":{"current":1, "total":100}}
{"error":"Invalid..."}
...
there is a wrapper written in go here, though I have not used it myself.