dockerdocker-in-docker

How to list Docker images built using DinD (Docker in Docker)


I'm using the DinD (Docker in Docker) approach to build some images. My hosting machine has Docker installed:

$  apt list --installed docker*
Listing... Done
docker-ce-cli/focal,now 5:20.10.22~3-0~ubuntu-focal amd64 [installed,upgradable to: 5:24.0.1-1~ubuntu.20.04~focal]
docker-ce-rootless-extras/focal,now 5:23.0.3-1~ubuntu.20.04~focal amd64 [installed,upgradable to: 5:24.0.1-1~ubuntu.20.04~focal]
docker-ce/focal,now 5:23.0.3-1~ubuntu.20.04~focal amd64 [installed,upgradable to: 5:24.0.1-1~ubuntu.20.04~focal]
docker-compose-plugin/focal,now 2.17.2-1~ubuntu.20.04~focal amd64 [installed,upgradable to: 2.18.1-1~ubuntu.20.04~focal]
docker-scan-plugin/focal,now 0.23.0~ubuntu-focal amd64 [installed,automatic]

I'm using docker:20.10.12-dind with a host machine directory mounted as /var/lib/docker to build a Docker image. After the image is built, how can I get the image information from the host machine? docker images ls -a in the host machine returns nothing.


Solution

  • Just run docker command from inside the container.

    docker exec the_container_running_dind docker image ls