Chris00 / ocaml-docker

Binding to the Docker Remote API
ISC License
28 stars 6 forks source link

problems with Container.Exec #4

Closed gitoleg closed 5 years ago

gitoleg commented 5 years ago

Hi, I've got some problems trying to run the next simple code:

  let source = Image.from_image ~tag:"latest" "debian" in
  Image.create source;
  let id = Container.create "debian:latest"  ["bash"; "-s"; ]  in
  Container.start id;
  let e = Container.Exec.create id ["ls"; "-l"; ] in
  let stream = Container.Exec.start e in
  Container.stop id;
  Container.rm id

In my understanding, Container.Exec runs a command in a running container, but I got

 OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "process_linux.go:91: executing setns process caused \"exit status 21\"": unknown

when try to output stream content. So the question is what am I doing wrong?

Chris00 commented 5 years ago

I think "bash" is no longer running because stdin was not attached. Use

let id = Container.create "debian:latest"  ["bash"; "-s"; ] ~open_stdin:true
gitoleg commented 5 years ago

ok, thanks!