This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Detect privileged containers | |
SELECT name, image, status | |
FROM docker_containers | |
WHERE privileged=1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- See users who can access the Docker daemon | |
SELECT u.username | |
FROM user_groups ug | |
LEFT JOIN users u ON u.uid=ug.uid | |
WHERE ug.gid IN ( | |
SELECT gid FROM groups WHERE groupname="docker" | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Search for a specific environment variable in all containers | |
SELECT name, env_variables | |
FROM docker_containers | |
WHERE env_variables LIKE "%NGINX_VERSION%"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Detect profiles that are not running with AppArmor | |
SELECT name, image, state | |
FROM docker_containers | |
WHERE security_options NOT LIKE "%apparmor%"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Detect contains with process that run with the root user | |
SELECT containers.name, processes.pid, processes.name, cmdline, user | |
FROM docker_container_processes processes | |
JOIN docker_containers containers ON containers.id=processes.id | |
WHERE processes.id IN ( | |
SELECT id FROM docker_containers | |
) AND user="root"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Retrieve images not used in active containers | |
SELECT id, tags | |
FROM docker_images | |
WHERE id NOT IN ( | |
SELECT image_id FROM docker_containers | |
); |