package docker-api
Library
Module
Module type
Parameter
Class
Class type
type t = {
id : id;
(*Identifier of the container.
*)names : string list;
(*Names given to the container.
*)image : string;
(*Name of the image used to create the container.
*)command : string;
(*Command passed to the container.
*)created : float;
(*Unix time of creation.
*)status : string;
(*Human readable status.
*)ports : port list;
size_rw : int option;
size_root_fs : int option;
}
type bind =
| Vol of string
(*create a new volume for the container
*)| Mount of string * string
(*
*)Mount(host_path, container_path)
bind-mount a host path into the container. A relativehost_path
will be interpreted as relative to the current working directory (at the time of the function calling this binding).container_path
must be an absolute path inside the container.| Mount_ro of string * string
(*As
*)Mount
but make the bind-mount read-only inside the container.
val list :
?addr:Unix.sockaddr ->
?all:bool ->
?limit:int ->
?size:bool ->
?before:id_or_name ->
?exited:int list ->
?health:[ `Starting | `Healthy | `Unhealthy | `None ] list ->
?name:string list ->
?since:id_or_name ->
?status:
[ `Created
| `Restarting
| `Running
| `Removing
| `Paused
| `Exited
| `Dead ]
list ->
?volume:string ->
unit ->
t list
list ()
lists running containers (or all containers if ~all
is set to true
).
type host_config = {
memory : int;
(*Memory limit in bytes.
*)cgroup_parent : string;
(*Path to cgroups under which the container's cgroup is created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups are created if they do not already exist.
*)blk_io_weight : int;
(*Block IO weight (relative weight). Values outside
*)0 .. 1000
do not set this field.cpu_period : int;
(*The length of a CPU period in microseconds. Non-positive values do not set this field.
*)memory_swap : int;
(*Total memory limit (memory + swap). Set as -1 to enable unlimited swap.
*)binds : bind list;
(*A list of volume bindings for this container.
*)network_mode : string;
(*Network mode to use for this container. Supported standard values are: bridge, host, none, and container:<name|id>. Any other value is taken as a custom network's name to which this container should connect to.
*)policy : [ `None | `Auto_remove | `Restart_always | `Restart_unless_stopped | `Restart_on_failure of int ];
(*The behavior to apply when the container exits. The default is not to restart and not to remove the container (
`None
). An ever increasing delay (double the previous delay, starting at 100ms) is added before each restart to prevent flooding the server.`Auto_remove
Automatically remove the container when the container's process exits.`Restart_always
Always restart.`Restart_unless_stopped
Restart always except when the user has manually stopped the container.`Restart_on_failure n
Restart only when the container exit code is non-zero. The numbern
says how many times to retry before giving up.
}
val host :
?cpu_shares:int ->
?memory:int ->
?cgroup_parent:string ->
?blk_io_weight:int ->
?cpu_period:int ->
?memory_swap:int ->
?binds:bind list ->
?network_mode:string ->
?policy:
[ `Auto_remove
| `None
| `Restart_always
| `Restart_on_failure of int
| `Restart_unless_stopped ] ->
unit ->
host_config
Return the default host configuration changed according to which optional labels were set.
val create :
?addr:Unix.sockaddr ->
?hostname:string ->
?domainname:string ->
?user:string ->
?stdin:bool ->
?stdout:bool ->
?stderr:bool ->
?open_stdin:bool ->
?stdin_once:bool ->
?env:string list ->
?workingdir:string ->
?networking:bool ->
?host:host_config ->
?name:string ->
string ->
string list ->
id
create image cmd
create a container and returns its ID where image
is the image name to use for the container and cmd
the command to run. cmd
has the form [prog; arg1;...; argN]
. BEWARE that the output of cmd
(on stdout and stderr) will be logged by the container (see logs
) so it will consume disk space.
val changes :
?addr:Unix.sockaddr ->
id ->
(string * [ `Modified | `Added | `Deleted ]) list
changes conn id
returns which files in a container's filesystem have been added, deleted, or modified.
export conn id
export the contents of container id
.
val start : ?addr:Unix.sockaddr -> ?detach_keys:string -> id -> unit
start id
starts the container id
.
val stop : ?addr:Unix.sockaddr -> ?wait:int -> id -> unit
stop id
stops the container id
.
val wait : ?addr:Unix.sockaddr -> id -> int
wait id
block until a container id
stops, then returns the exit code.
val restart : ?addr:Unix.sockaddr -> ?wait:int -> id -> unit
restart id
restart the container id
.
val kill : ?addr:Unix.sockaddr -> ?signal:int -> id -> unit
kill id
kill the container id
.
val pause : ?addr:Unix.sockaddr -> id -> unit
pause id
pause the container id
.
val unpause : ?addr:Unix.sockaddr -> id -> unit
unpause id
unpause the container id
.
val attach :
?addr:Unix.sockaddr ->
?stdin:bool ->
?stdout:bool ->
?stderr:bool ->
id ->
[ `Logs | `Stream | `Logs_and_stream ] ->
Stream.t
attach id what
view or interact with any running container id
primary process (pid 1).
- If
what = `Logs
replay the logs from the container: you will get the output since the container started. - If
what = `Stream
, streamstdin
,stdout
andstderr
(if enabled) from the time the request was made onwards. - If
what = `Logs_and_stream
after getting the output of`Logs
, it will seamlessly transition into streaming current output.
val rm :
?addr:Unix.sockaddr ->
?volumes:bool ->
?force:bool ->
?link:bool ->
id ->
unit
rm id
remove the container id
from the filesystem.
module Exec : sig ... end