STASIS
A pipeline delivery generator
Loading...
Searching...
No Matches
docker.h File Reference
#include "core.h"
Include dependency graph for docker.h:

Go to the source code of this file.

Data Structures

struct  DockerCapabilities
 

Macros

#define STASIS_DOCKER_QUIET   1 << 1
 Flag to squelch output from docker_exec()
 
#define STASIS_DOCKER_QUIET_STDOUT   1 << 2
 
#define STASIS_DOCKER_QUIET_STDERR   1 << 3
 
#define STASIS_DOCKER_BUILD   1 << 1
 Flag for older style docker build.
 
#define STASIS_DOCKER_BUILD_X   1 << 2
 Flag for docker buildx.
 
#define STASIS_DOCKER_IMAGE_COMPRESSION   "zstd"
 Compress "docker save"ed images with a compression program.
 

Functions

int docker_capable (struct DockerCapabilities *result)
 
int docker_exec (const char *args, unsigned flags)
 
int docker_build (const char *dirpath, const char *args, int engine)
 
int docker_script (const char *image, char *args, char *data, unsigned flags)
 
int docker_save (const char *image, const char *destdir, const char *compression_program)
 
void docker_sanitize_tag (char *str)
 
int docker_validate_compression_program (char *prog)
 

Function Documentation

◆ docker_build()

int docker_build ( const char * dirpath,
const char * args,
int engine )

Build a docker image

struct DockerCapabilities docker_is;
docker_capable(&docker_is);
if (docker_is.usable) {
printf("Building docker image\n");
if (docker_build("path/to/Dockerfile/dir")) {
fprintf("Docker build failed\n");
exit(1);
}
} else {
fprintf(stderr, "No usable docker installation available\n");
}
int docker_capable(struct DockerCapabilities *result)
Definition docker.c:151
int docker_build(const char *dirpath, const char *args, int engine)
Definition docker.c:65
Definition docker.h:20
Parameters
dirpath
args
engine
Returns

◆ docker_capable()

int docker_capable ( struct DockerCapabilities * result)

Determine the state of docker on the system

struct DockerCapabilities docker_is;
if (!docker_capable(&docker_is)) {
fprintf(stderr, "%s is %savailable, and %susable\n",
docker_is.podman ? "Podman" : "Docker",
docker_is.available ? "" : "not ",
docker_is.usable ? "" : "not ");
exit(1);
}
Parameters
resultDockerCapabilities struct
Returns
1 on success, 0 on error
Here is the call graph for this function:

◆ docker_exec()

int docker_exec ( const char * args,
unsigned flags )

Execute a docker command

Use the STASIS_DOCKER_QUIET flag to suppress all output from stdout and stderr.

if (docker_exec("run --rm -t ubuntu:latest /bin/bash -c 'echo Hello world'", 0)) {
fprintf(stderr, "Docker hello world failed\n");
exit(1);
}
int docker_exec(const char *args, unsigned flags)
Definition docker.c:4
Parameters
argsarguments to pass to docker
flags
Returns
exit code from "docker"