Skip to content

Commit

Permalink
Merge pull request #6051 from BOINC/dpa_docker_wrapper2
Browse files Browse the repository at this point in the history
docker wrapper: if image name specified in config file, use it and don't delete
  • Loading branch information
AenBleidd authored Feb 2, 2025
2 parents ada8a6c + 733d769 commit c47f315
Showing 1 changed file with 19 additions and 4 deletions.
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

0 comments on commit c47f315

Please sign in to comment.