go - Grab output from container in Docker SDK -


i'm trying run container using docker sdk golang , can't output container. i'm using following code that runs container, doesn't sends stderr , stdout of application. can advice i'm doing wrong?

type dckr struct {     cli      *client.client     username string     password string     addr     string     ctx      context.context }  func (d *dckr) run(containername string, image string, command []string, bind []string, stdout io.writer, stderr io.writer) error {     log.printf("[create] %s -> %s \n", image, containername)      res, err := d.cli.containercreate(         d.ctx,         &container.config{             user:         "root",             attachstdout: true,             attachstderr: true,             image:        image,             cmd:          command,         },         &container.hostconfig{             autoremove: true,             binds:      bind,         },         &network.networkingconfig{},         containername,     )      if err != nil {         log.println("[create] failed. %s", err)         return err     }     defer d.cli.containerremove(d.ctx, res.id, types.containerremoveoptions{force: true})      log.printf("[create] id: %s \n", res.id)     wrn := range res.warnings {         log.printf("[create] %s \n", wrn)     }      rsp, err := d.cli.containerattach(d.ctx, containername, types.containerattachoptions{         stream: false,         stdout: true,         stderr: true,         logs:   true,     })      if err != nil {         log.printf("[attach] fail. %s \n", err)         return err     }     log.printf("[attach] %s", res.id)     defer rsp.close()      err = d.cli.containerstart(d.ctx, res.id, types.containerstartoptions{})     if err != nil {         log.printf("[run] fail. %s \n", err)         return err     }      _, err = stdcopy.stdcopy(stdout, stderr, rsp.reader)     return err } 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -