Skip to content

Commit 2db609b

Browse files
authored
Support another way of spawning docker containers without image name (#1207)
The hash prefix is optional, but can be specified.
1 parent 47efcc4 commit 2db609b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

userspace/libsinsp/container.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,15 @@ bool sinsp_container_engine_docker::parse_docker(sinsp_container_manager* manage
189189
container->m_imageid = imgstr.substr(cpos + 1);
190190
}
191191

192+
// containers can be spawned using just the imageID as image name,
193+
// with or without the hash prefix (e.g. sha256:)
192194
bool no_name = !container->m_imageid.empty() &&
193195
strncmp(container->m_image.c_str(), container->m_imageid.c_str(),
194196
MIN(container->m_image.length(), container->m_imageid.length())) == 0;
197+
no_name |= !imgstr.empty() &&
198+
strncmp(container->m_image.c_str(), imgstr.c_str(),
199+
MIN(container->m_image.length(), imgstr.length())) == 0;
200+
195201
if(!no_name || !m_query_image_info)
196202
{
197203
string hostname, port;

0 commit comments

Comments
 (0)