@@ -124,6 +124,9 @@ struct CONFIG {
124124 string project_dir_mount;
125125 // mount project dir here in container
126126 // default: don't mount it
127+ string image_name;
128+ // use this as the image name, and don't delete it when done.
129+ // For testing.
127130 void print () {
128131 fprintf (stderr, " Wrapper config file:\n " );
129132 if (!workdir.empty ()) {
@@ -173,6 +176,10 @@ int parse_config_file() {
173176 if (x) {
174177 config.project_dir_mount = x->as <string>();
175178 }
179+ x = v.find (" image_name" );
180+ if (x) {
181+ config.image_name = x->as <string>();
182+ }
176183 return 0 ;
177184}
178185
@@ -190,8 +197,12 @@ int error_output(vector<string> &out) {
190197// //////// IMAGE ////////////
191198
192199void get_image_name () {
193- string s = docker_image_name (project_dir, aid.wu_name );
194- strcpy (image_name, s.c_str ());
200+ if (config.image_name .empty ()) {
201+ string s = docker_image_name (project_dir, aid.wu_name );
202+ strcpy (image_name, s.c_str ());
203+ } else {
204+ strcpy (image_name, config.image_name .c_str ());
205+ }
195206}
196207
197208int image_exists (bool &exists) {
@@ -341,8 +352,12 @@ void cleanup() {
341352 sprintf (cmd, " container rm %s" , container_name);
342353 docker_conn.command (cmd, out);
343354
344- sprintf (cmd, " image rm %s" , image_name);
345- docker_conn.command (cmd, out);
355+ // don't remove image if it was specified in config
356+ //
357+ if (config.image_name .empty ()) {
358+ sprintf (cmd, " image rm %s" , image_name);
359+ docker_conn.command (cmd, out);
360+ }
346361}
347362
348363void poll_client_msgs () {
0 commit comments