diff --git a/samples/docker_wrapper/docker_wrapper.cpp b/samples/docker_wrapper/docker_wrapper.cpp index 0d60234f05..e0e501b4ae 100644 --- a/samples/docker_wrapper/docker_wrapper.cpp +++ b/samples/docker_wrapper/docker_wrapper.cpp @@ -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()) { @@ -173,6 +176,10 @@ int parse_config_file() { if (x) { config.project_dir_mount = x->as(); } + x = v.find("image_name"); + if (x) { + config.image_name = x->as(); + } return 0; } @@ -190,8 +197,12 @@ int error_output(vector &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) { @@ -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() {