29 #ifndef DOCKER_CONTAINERS_H_
30 #define DOCKER_CONTAINERS_H_
36 #include <coll_arraylist.h>
51 #define free_docker_ctr_port(ctr_port) json_object_put((json_object*) ctr_port)
59 #define docker_ctr_port_type_get(ctr_port) get_attr_str((json_object*)ctr_port, "Type")
67 #define docker_ctr_port_private_port_get(ctr_port) get_attr_long((json_object*)ctr_port, "PrivatePort")
75 #define docker_ctr_port_public_port_get(ctr_port) get_attr_long((json_object*)ctr_port, "PublicPort")
87 #define free_docker_ctr_ls_item(ctr) json_object_put((json_object*) ctr)
95 #define docker_ctr_ls_item_id_get(ctr) get_attr_str((json_object*)ctr, "Id")
103 #define docker_ctr_ls_item_names_get(ctr) get_attr_json_object((json_object*)ctr, "Names")
111 #define docker_ctr_ls_item_names_length(ctr) json_object_array_length(docker_ctr_ls_item_names_get(ctr))
120 #define docker_ctr_ls_item_names_get_idx(ctr, i) (char*) json_object_get_string(json_object_array_get_idx(docker_ctr_ls_item_names_get(ctr), i))
128 #define docker_ctr_ls_item_image_get(ctr) get_attr_str((json_object*)ctr, "Image")
136 #define docker_ctr_ls_item_image_id_get(ctr) get_attr_str((json_object*)ctr, "ImageID")
144 #define docker_ctr_ls_item_command_get(ctr) get_attr_str((json_object*)ctr, "Command")
152 #define docker_ctr_ls_item_created_get(ctr) get_attr_long_long((json_object*)ctr, "Created")
160 #define docker_ctr_ls_item_state_get(ctr) get_attr_str((json_object*)ctr, "State")
168 #define docker_ctr_ls_item_status_get(ctr) get_attr_str((json_object*)ctr, "Status")
176 #define docker_ctr_ls_item_size_rw_get(ctr) get_attr_long_long((json_object*)ctr, "SizeRw")
184 #define docker_ctr_ls_item_size_root_fs_get(ctr) get_attr_long_long((json_object*)ctr, "SizeRootFs")
192 #define docker_ctr_ls_item_ports_get(ctr) get_attr_json_object((json_object*)ctr, "Ports")
200 #define docker_ctr_ls_item_ports_length(ctr) json_object_array_length(docker_ctr_ls_item_ports_get(ctr))
209 #define docker_ctr_ls_item_ports_get_idx(ctr, i) (docker_ctr_port*) json_object_array_get_idx(docker_ctr_ls_item_ports_get(ctr), i)
217 #define docker_ctr_ls_item_ports_labels_get(ctr) get_attr_json_object((json_object*)ctr, "Labels")
224 #define docker_ctr_ls_item_ports_labels_foreach(ctr) json_object_object_foreach(docker_ctr_ls_item_ports_labels_get(ctr), key, val)
237 #define free_docker_ctr_list(ctr_ls) json_object_put(ctr_ls)
245 #define docker_ctr_list_length(ctr_ls) json_object_array_length(ctr_ls)
254 #define docker_ctr_list_get_idx(ctr_ls, i) (docker_ctr*) json_object_array_get_idx(ctr_ls, i)
268 int all,
int limit,
int size, ...);
282 int all,
int limit,
int size,
const char* filters);
294 #define make_docker_ctr_create_params (docker_ctr_create_params*)json_object_new_object
301 #define free_docker_ctr_create_params(ctr_create) json_object_put(ctr_create)
309 #define docker_ctr_create_params_image_set(ctr_create, img) set_attr_str(ctr_create, "Image", img)
317 #define docker_ctr_create_params_entrypoint_set(ctr_create, entry) set_attr_str(ctr_create, "Entrypoint", entry)
325 #define docker_ctr_create_params_cmd_add(ctr_create, cmd) add_array_str(ctr_create, "Cmd", cmd)
333 #define docker_ctr_create_params_env_add(ctr_create, env) add_array_str(ctr_create, "Env", env)
341 #define docker_ctr_create_params_tty_set(ctr_create, tty) set_attr_boolean(ctr_create, "Tty", tty)
349 #define docker_ctr_create_params_openstdin_set(ctr_create, openstdin) set_attr_boolean(ctr_create, "OpenStdin", openstdin)
357 #define docker_ctr_create_params_attachstdin_set(ctr_create, attachstdin) set_attr_boolean(ctr_create, "AttachStdin", attachstdin)
365 #define docker_ctr_create_params_attachstdout_set(ctr_create, attachstdout) set_attr_boolean(ctr_create, "AttachStdout", attachstdout)
373 #define docker_ctr_create_params_attachstderr_set(ctr_create, attachstderr) set_attr_boolean(ctr_create, "AttachStderr", attachstderr)
401 #define free_docker_ctr(ctr) json_object_put((json_object*) ctr)
409 #define docker_ctr_id_get(ctr) get_attr_str((json_object*)ctr, "Id")
417 #define docker_ctr_image_get(ctr) get_attr_str((json_object*)ctr, "Image")
425 #define docker_ctr_name_get(ctr) get_attr_str((json_object*)ctr, "Name")
433 #define docker_ctr_path_get(ctr) get_attr_str((json_object*)ctr, "Path")
441 #define docker_ctr_created_get(ctr) get_attr_long_long((json_object*)ctr, "Created")
449 #define docker_ctr_state_get(ctr) get_attr_str((json_object*)ctr, "State")
457 #define docker_ctr_status_get(ctr) get_attr_str((json_object*)ctr, "Status")
465 #define docker_ctr_size_rw_get(ctr) get_attr_long_long((json_object*)ctr, "SizeRw")
473 #define docker_ctr_size_root_fs_get(ctr) get_attr_long_long((json_object*)ctr, "SizeRootFs")
481 #define docker_ctr_ports_get(ctr) get_attr_json_object((json_object*)ctr, "Ports")
489 #define docker_ctr_ports_length(ctr) json_object_array_length(docker_ctr_ports_get(ctr))
498 #define docker_ctr_ports_get_idx(ctr, i) (docker_ctr_port*) json_object_array_get_idx(docker_ctr_ports_get(ctr), i)
506 #define docker_ctr_ports_labels_get(ctr) get_attr_json_object((json_object*)ctr, "Labels")
513 #define docker_ctr_ports_labels_foreach(ctr) json_object_object_foreach(docker_ctr_ports_labels_get(ctr), key, val)
547 #define docker_ctr_process_details_length(ctr_ps_ls) json_object_array_length(ctr_ps_ls)
556 #define docker_ctr_process_details_get_idx(ctr_ps_ls, i) (char*) json_object_array_get_idx(ctr_ps_ls, i)
568 #define free_docker_ctr_ps(ctr_ps) json_object_put((json_object*) ctr_ps)
576 #define docker_ctr_ps_titles_get(ctr_ps) get_attr_json_object((json_object*)ctr_ps, "Titles")
584 #define docker_ctr_ps_titles_length(ctr_ps) json_object_array_length(docker_ctr_ps_titles_get(ctr_ps))
593 #define docker_ctr_ps_titles_get_idx(ctr_ps, i) (char*) json_object_get_string(json_object_array_get_idx(docker_ctr_ps_titles_get(ctr_ps), i))
601 #define docker_ctr_ps_processes_get(ctr_ps) get_attr_json_object((json_object*)ctr_ps, "Processes")
609 #define docker_ctr_ps_processes_length(ctr_ps) json_object_array_length(docker_ctr_ps_processes_get(ctr_ps))
618 #define docker_ctr_ps_processes_get_idx(ctr_ps, i) (docker_ctr_process_details*) json_object_array_get_idx(docker_ctr_ps_processes_get(ctr_ps), i)
651 int std_out,
int std_err,
long since,
long until,
int timestamps,
int tail);
675 DOCKER_FS_MODIFIED = 0, DOCKER_FS_ADDED = 1, DOCKER_FS_DELETED = 2
696 const char* path,
const char* kind);
769 #define docker_percpu_usage_list_length(percpu_usage_ls) json_object_array_length(percpu_usage_ls)
778 #define docker_percpu_usage_list_get_idx(percpu_usage_ls, i) (docker_percpu_usage*) json_object_array_get_idx(percpu_usage_ls, i)
790 #define free_docker_cpu_usage(cpu_usg) json_object_put((json_object*) cpu_usg)
798 #define docker_cpu_usage_usermode_get(cpu_usg) get_attr_long_long((json_object*)cpu_usg, "usage_in_usermode")
806 #define docker_cpu_usage_total_get(cpu_usg) get_attr_long_long((json_object*)cpu_usg, "total_usage")
814 #define docker_cpu_usage_kernelmode_get(cpu_usg) get_attr_long_long((json_object*)cpu_usg, "usage_in_kernelmode")
822 #define docker_cpu_usage_percpu_usage_get(cpu_usg) (docker_percpu_usage_list*)get_attr_json_object((json_object*)cpu_usg, "percpu_usage")
834 #define free_docker_throttling_data(throt) json_object_put((json_object*) throt)
842 #define docker_throttling_data_periods_get(throt) get_attr_long_long((json_object*)throt, "periods")
850 #define docker_throttling_data_throttled_periods_get(throt) get_attr_long_long((json_object*)throt, "throttled_periods")
858 #define docker_throttling_data_throttled_time_get(throt) get_attr_long_long((json_object*)throt, "throttled_time")
870 #define free_docker_container_cpu_stats(cpu_stats) json_object_put((json_object*) cpu_stats)
878 #define docker_container_cpu_stats_system_cpu_usage_get(cpu_stats) get_attr_long_long((json_object*)cpu_stats, "system_cpu_usage")
886 #define docker_container_cpu_stats_online_cpus_get(cpu_stats) get_attr_long((json_object*)cpu_stats, "online_cpus")
894 #define docker_container_cpu_stats_cpu_usage_get(cpu_stats) (docker_cpu_usage*)get_attr_json_object((json_object*)cpu_stats, "cpu_usage")
902 #define docker_container_cpu_stats_throttling_data_get(cpu_stats) (docker_throttling_data*)get_attr_json_object((json_object*)cpu_stats, "throttling_data")
914 #define free_docker_container_mem_stats(mem_stats) json_object_put((json_object*) mem_stats)
922 #define docker_container_mem_stats_max_usage_get(mem_stats) get_attr_long_long((json_object*)mem_stats, "max_usage")
930 #define docker_container_mem_stats_usage_get(mem_stats) get_attr_long_long((json_object*)mem_stats, "usage")
938 #define docker_container_mem_stats_failcnt_get(mem_stats) get_attr_long_long((json_object*)mem_stats, "failcnt")
946 #define docker_container_mem_stats_limit_get(mem_stats) get_attr_long_long((json_object*)mem_stats, "limit")
954 #define docker_container_mem_stats_stats_get(mem_stats) get_attr_json_object((json_object*)mem_stats, "stats")
961 #define docker_container_mem_stats_stats_foreach(mem_stats) json_object_object_foreach(docker_container_mem_stats_stats_get(mem_stats), key, val)
973 #define free_docker_container_net_stats(net_stats) json_object_put((json_object*) net_stats)
980 #define docker_container_net_stats_foreach(net_stats) json_object_object_foreach(net_stats, key, val)
987 #define docker_container_net_stats_stats_foreach(net_stats_val) json_object_object_foreach(net_stats_val, key, val)
999 #define free_docker_container_pid_stats(pid_stats) json_object_put((json_object*) pid_stats)
1006 #define docker_container_pid_stats_foreach(pid_stats) json_object_object_foreach(pid_stats, key, val)
1025 #define free_docker_container_stats(stats) json_object_put((json_object*) stats)
1033 #define docker_container_stats_read_get(stats) get_attr_str((json_object*)stats, "read")
1041 #define docker_container_stats_pid_stats_get(stats) (docker_container_pid_stats*)get_attr_json_object((json_object*)stats, "pid_stats")
1049 #define docker_container_stats_networks_get(stats) (docker_container_net_stats*)get_attr_json_object((json_object*)stats, "networks")
1057 #define docker_container_stats_mem_stats_get(stats) (docker_container_mem_stats*)get_attr_json_object((json_object*)stats, "memory_stats")
1065 #define docker_container_stats_cpu_stats_get(stats) (docker_container_cpu_stats*)get_attr_json_object((json_object*)stats, "cpu_stats")
1073 #define docker_container_stats_precpu_stats_get(stats) (docker_container_cpu_stats*)get_attr_json_object((json_object*)stats, "precpu_stats")
1097 void* cbargs),
void* cbargs,
char*
id);
1119 char*
id,
char* detachKeys);
1152 char*
id,
char* signal);
1163 char*
id,
char* name);
1195 char*
id,
char* condition);
1209 char*
id,
int v,
int force,
int link);
1225 char* detach_keys,
int logs,
int stream,
int attach_stdin,
int attach_stdout,
int attach_stderr);
int docker_changes_list_add(docker_changes_list *list, docker_container_change *item)
Add a container change item to the docker changes list.
Definition: docker_containers.c:309
d_err_t docker_container_attach_default(docker_context *ctx, char *id, char *detach_keys, int logs, int stream, int attach_stdin, int attach_stdout, int attach_stderr)
Attach to a container.
Definition: docker_containers.c:1199
d_err_t docker_wait_container(docker_context *ctx, char *id, char *condition)
Wait for a container.
Definition: docker_containers.c:614
json_object docker_throttling_data
Docker Throttling Data json object.
Definition: docker_containers.h:827
json_object docker_container_net_stats
Docker Container Net Stats json object.
Definition: docker_containers.h:966
change_kind
Enum for the change type of entry in filesystem changes.
Definition: docker_containers.h:674
json_object docker_cpu_usage
Docker cpu usage object.
Definition: docker_containers.h:783
struct docker_container_change_t docker_container_change
Docker container change struct.
d_err_t docker_container_get_stats_cb(docker_context *ctx, void(*docker_container_stats_cb)(docker_container_stats *stats, void *cbargs), void *cbargs, char *id)
Get stats from a running container. (the streaming version)
Definition: docker_containers.c:391
d_err_t docker_create_container(docker_context *ctx, char **id, docker_ctr_create_params *params)
Create a docker container given the container creation params.
Definition: docker_containers.c:120
json_object docker_container_pid_stats
Docker Container Pid Stats json object.
Definition: docker_containers.h:992
d_err_t docker_kill_container(docker_context *ctx, char *id, char *signal)
Kill a container.
Definition: docker_containers.c:516
json_object docker_container_mem_stats
Docker Container Memory Stats json object.
Definition: docker_containers.h:907
d_err_t make_docker_changes_list(docker_changes_list **changes_list)
Create a new docker changes list json object.
Definition: docker_containers.c:303
d_err_t docker_container_changes(docker_context *ctx, docker_changes_list **changes, char *id)
Definition: docker_containers.c:323
void() docker_log_line_handler(void *handler_args, int stream_id, int line_num, char *line)
function type for handling log lines received from the get logs api call.
Definition: docker_containers.h:656
docker_ctr * docker_inspect_container(docker_context *ctx, char *id, int size)
Inspect the docker container given by the id.
Definition: docker_containers.c:150
json_object docker_ctr_list
Docker Container List json object.
Definition: docker_containers.h:230
d_err_t docker_container_logs(docker_context *ctx, char **log, size_t *log_length, char *id, int follow, int std_out, int std_err, long since, long until, int timestamps, int tail)
Get the logs for the docker container.
Definition: docker_containers.c:176
void free_docker_container_change(docker_container_change *item)
Free the docker container change item.
Definition: docker_containers.c:294
json_object docker_ctr
Docker Container json object.
Definition: docker_containers.h:394
json_object docker_ctr_ls_item
Docker Container list item json object.
Definition: docker_containers.h:80
d_err_t docker_container_logs_foreach(void *handler_args, char *log, size_t log_length, docker_log_line_handler *line_handler)
Iterate the log lines received from the logs call.
Definition: docker_containers.c:237
d_err_t docker_container_get_stats(docker_context *ctx, docker_container_stats **stats, char *id)
Get stats from a running container. (the non-streaming version)
Definition: docker_containers.c:360
json_object docker_container_stats
Docker Container Stats object.
Definition: docker_containers.h:1018
float docker_container_stats_get_cpu_usage_percent(docker_container_stats *stats)
Get the cpu usage percentage from the docker container stats.
Definition: docker_containers.c:414
d_err_t docker_unpause_container(docker_context *ctx, char *id)
Unpause a container.
Definition: docker_containers.c:593
json_object docker_percpu_usage_list
Docker PerCPU usage list json object.
Definition: docker_containers.h:761
json_object docker_container_cpu_stats
Docker Container CPU stats json object.
Definition: docker_containers.h:863
d_err_t docker_container_list_filter_str(docker_context *ctx, docker_ctr_list **container_list, int all, int limit, int size, const char *filters)
Definition: docker_containers.c:87
json_object docker_ctr_process_details
Docker container process list object.
Definition: docker_containers.h:539
d_err_t docker_container_list(docker_context *ctx, docker_ctr_list **container_list, int all, int limit, int size,...)
Definition: docker_containers.c:39
arraylist docker_changes_list
Docker Changes list json object.
Definition: docker_containers.h:708
d_err_t docker_rename_container(docker_context *ctx, char *id, char *name)
Rename a container.
Definition: docker_containers.c:544
d_err_t docker_stop_container(docker_context *ctx, char *id, int t)
Stop a container.
Definition: docker_containers.c:451
d_err_t make_docker_container_change(docker_container_change **item, const char *path, const char *kind)
Create a new container change item.
Definition: docker_containers.c:272
d_err_t docker_restart_container(docker_context *ctx, char *id, int t)
Restart a container.
Definition: docker_containers.c:486
json_object docker_ctr_create_params
Docker Container Creation Parameters json object.
Definition: docker_containers.h:287
d_err_t docker_process_list_container(docker_context *ctx, docker_ctr_ps **ps, char *id, char *process_args)
List all processes in a container identified by id.
Definition: docker_containers.c:163
d_err_t docker_remove_container(docker_context *ctx, char *id, int v, int force, int link)
Remove a container.
Definition: docker_containers.c:634
docker_container_change * docker_changes_list_get_idx(docker_changes_list *list, int i)
Get the ith item from the docker changes list.
Definition: docker_containers.c:314
d_err_t docker_pause_container(docker_context *ctx, char *id)
Pause a container.
Definition: docker_containers.c:572
d_err_t docker_start_container(docker_context *ctx, char *id, char *detachKeys)
Start a container.
Definition: docker_containers.c:431
json_object docker_ctr_ps
Docker containers process details object.
Definition: docker_containers.h:561
json_object docker_ctr_port
Docker Container Port json object.
Definition: docker_containers.h:44
size_t docker_changes_list_length(docker_changes_list *list)
Get the length of the docker changes list.
Definition: docker_containers.c:319
enum _config_error d_err_t
Definition: docker_result.h:60
Docker container change struct.
Definition: docker_containers.h:682
change_kind kind
change type for the entry
Definition: docker_containers.h:684
char * path
path which is changed
Definition: docker_containers.h:683
A docker context for a specific docker server.
Definition: docker_connection_util.h:141