Docker: Part 2 — Recon & Enumeration

Now that you understand what Docker is and why it’s widely used, it’s time to learn how to detect Docker in an environment and begin enumerating it for privilege escalation opportunities.

This post covers:

  • How to detect Docker on a system
  • How to tell if you’re inside a container
  • How to find misconfigured Docker sockets
  • Enumeration techniques to uncover escalation paths

When you land a shell, you may already be inside a Docker container. Here are ways to confirm it.

cat /proc/1/cgroup

If you see paths referencing /docker/, you’re most likely inside a container.

ls -la /.dockerenv

This file is often present inside Docker containers unless explicitly removed.

hostname

If it looks like a hash or random ID, that’s another indicator of a containerized environment.

To check if Docker is installed:

which docker
docker --version

Also look for the Docker socket:

ls -l /var/run/docker.sock

If this file exists and is writable, Docker is likely running and may be vulnerable to abuse.

Check your group memberships:

id

If you see docker in the group list, you can interact with the Docker daemon. This is a direct privilege escalation path because you can start containers with host-level access.

If you have Docker access, start by enumerating images and containers.

docker images
docker ps
docker ps -a
docker logs <container_id>
docker volume ls
docker volume inspect <volume_name>

Volumes may contain application data, configuration files, or credentials.

Use docker inspect to gather details about mounts, environment variables, and privileges.

docker inspect <container_id>

Look for:

  • Mounted volumes
  • Sensitive environment variables (e.g., API keys, secrets)
  • "Privileged": true entries

If a container is started with the --privileged flag, it has extended access to the host system and devices.

Check using:

docker inspect <container_id> | grep -i privileged

If true, you may be able to escape the container or interact with host-level devices like /dev/mem.

If you’re inside a container, continue your recon:

id
whoami
ls /dev
capsh --print

Look for dangerous ones like cap_sys_admin or cap_net_admin.

mount
df -h

If you see the host’s root filesystem mounted, or directories like /host, that could be an escape path.

What to CheckPurpose
/proc/1/cgroup, /.dockerenvConfirm container presence
/var/run/docker.sockDocker control access
Group membership for dockerPrivilege escalation vector
docker inspect outputMounts, secrets, privileged flags
capsh, mount, ls /devBreakout and privilege abuse opportunities

In Part 3, we’ll weaponize this knowledge. You’ll learn how to:

  • Exploit Docker group membership
  • Abuse the Docker socket
  • Launch containers that mount the host filesystem
  • Escape containers using chroot
  • Run privileged containers for full host access

Scroll to Top