Coder Social home page Coder Social logo

Comments (3)

almoehi avatar almoehi commented on June 4, 2024

Hi,
I agree, this is a pretty helpful use case.

I'm not sure if this usecase is supported by docker`s remote API at all (but I think so).

As for reactive-docker, it should be possible. The futures should return upon receiving any response from the docker server. Now, I don't know the behavour of the docker server when attaching to a non-running container. Maybe it only sends some response when the container is being started.

I think we have to try this - will try to write a simple test case like this:

- create new container
- attach to container
- start container

is this the way you'd like it to work ?

from reactive-docker.

almoehi avatar almoehi commented on June 4, 2024

Ok, so this is the test case I came up with and which works fine with the current version of reactive-docker:

      env.containerId.id must not be empty
      val (it, en) = Concurrent.joined[Array[Byte]]
      val maybeRes = (en &> DockerEnumeratee.rawStream |>>> Iteratee.head)

      val attached = docker.attachStream(env.containerId, true, true, true)(it).flatMap(_.run)
      val run = await(docker.containerStart(env.containerId))

      val res = await(maybeRes)
      res must not be empty
      res.get.channel must be_==(0)
      res.get.text must be_==("hello world")

note:
You do not want to wait for the attached future to complete as this might never happen. You are attaching to a (possibly) infinite stream, so the future will never complete as the HTTP connection will never complete as well.

Instead, you should wait for your consumer iteratee to complete (if it is designed to complete)
Does this work for you ?

from reactive-docker.

jakajancar avatar jakajancar commented on June 4, 2024

Haven't tested it yet, but yes, I think it should work.

Btw, create+attach+start is also how docker run works.

from reactive-docker.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.