@@ -1233,7 +1233,7 @@ int HOST_INFO::get_virtualbox_version() {
12331233 return 0 ;
12341234}
12351235
1236- // check if docker is installed on this host
1236+ // check if docker/podman is installed on this host
12371237// populate docker_version on success
12381238//
12391239bool HOST_INFO::get_docker_version_aux (DOCKER_TYPE type){
@@ -1246,8 +1246,8 @@ bool HOST_INFO::get_docker_version_aux(DOCKER_TYPE type){
12461246#endif
12471247 string cmd = string (docker_cli_prog (type)) + " --version 2>/dev/null" ;
12481248 FILE* f = popen (cmd.c_str (), " r" );
1249+ char buf[256 ];
12491250 if (f) {
1250- char buf[256 ];
12511251 // normally the version is on the first line,
12521252 // but it's on the 2nd line if using podman-docker
12531253 //
@@ -1262,6 +1262,32 @@ bool HOST_INFO::get_docker_version_aux(DOCKER_TYPE type){
12621262 }
12631263 pclose (f);
12641264 }
1265+ #ifdef __linux__
1266+ // if we're running as an unprivileged user, Docker/podman may not work.
1267+ // Check by running the Hello World image.
1268+ //
1269+ // Since we do this every time on startup, don't delete the image.
1270+ //
1271+ cmd = string (docker_cli_prog (type)) + " run hello-world 2>/dev/null" ;
1272+ bool found = false ;
1273+ f = popen (cmd.c_str (), " r" );
1274+ if (f) {
1275+ while (fgets (buf, 256 , f)) {
1276+ if (strstr (buf, " Hello" )) {
1277+ found = true ;
1278+ break ;
1279+ }
1280+ }
1281+ pclose (f);
1282+ }
1283+ if (!found) {
1284+ msg_printf (NULL , MSG_INFO,
1285+ " %s found but 'hello-world' test failed" ,
1286+ docker_type_str (type)
1287+ );
1288+ docker_version[0 ] = 0 ;
1289+ }
1290+ #endif
12651291 return ret;
12661292}
12671293
0 commit comments