Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions samples/docker_wrapper/docker_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ struct CONFIG {
string project_dir_mount;
// mount project dir here in container
// default: don't mount it
string image_name;
// use this as the image name, and don't delete it when done.
// For testing.
void print() {
fprintf(stderr, "Wrapper config file:\n");
if (!workdir.empty()) {
Expand Down Expand Up @@ -173,6 +176,10 @@ int parse_config_file() {
if (x) {
config.project_dir_mount = x->as<string>();
}
x = v.find("image_name");
if (x) {
config.image_name = x->as<string>();
}
return 0;
}

Expand All @@ -190,8 +197,12 @@ int error_output(vector<string> &out) {
////////// IMAGE ////////////

void get_image_name() {
string s = docker_image_name(project_dir, aid.wu_name);
strcpy(image_name, s.c_str());
if (config.image_name.empty()) {
string s = docker_image_name(project_dir, aid.wu_name);
strcpy(image_name, s.c_str());
} else {
strcpy(image_name, config.image_name.c_str());
}
}

int image_exists(bool &exists) {
Expand Down Expand Up @@ -341,8 +352,12 @@ void cleanup() {
sprintf(cmd, "container rm %s", container_name);
docker_conn.command(cmd, out);

sprintf(cmd, "image rm %s", image_name);
docker_conn.command(cmd, out);
// don't remove image if it was specified in config
//
if (config.image_name.empty()) {
sprintf(cmd, "image rm %s", image_name);
docker_conn.command(cmd, out);
}
}

void poll_client_msgs() {
Expand Down