Port-based streaming for long-running Docker commands.
A BEAM-native extension not present in the Rust crate. Useful for
docker logs --follow, docker events, docker build, etc.
Lines are sent as messages to the subscriber process:
{:docker_stream, pid, {:stdout, line}}
{:docker_stream, pid, {:exit, exit_code}}Examples
# Stream logs from a container
{:ok, stream} = Docker.Stream.start_link(
Docker.Commands.Logs.new("my-container") |> Docker.Commands.Logs.follow(),
subscriber: self()
)
receive do
{:docker_stream, ^stream, {:stdout, line}} ->
IO.puts("LOG: #{line}")
{:docker_stream, ^stream, {:exit, 0}} ->
IO.puts("Stream ended")
end
# Stop streaming
Docker.Stream.stop(stream)Options
:subscriber- PID to receive stream messages (required):config-Docker.Configto use (default:Docker.Config.new())
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts a streaming process for the given command.
Stops the streaming process.
Types
@type stream_message() :: {:docker_stream, pid(), {:stdout, String.t()}} | {:docker_stream, pid(), {:exit, non_neg_integer()}}
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec start_link(struct(), keyword()) :: GenServer.on_start()
Starts a streaming process for the given command.
@spec stop(GenServer.server()) :: :ok
Stops the streaming process.