cruizba / ubuntu-dind

A docker image based in ubuntu to run docker containers inside docker containers
Apache License 2.0
169 stars 76 forks source link

Question: removing the /var/lib/docker volume causes issue #27

Closed sami-sweng closed 4 weeks ago

sami-sweng commented 4 months ago

I tried to remove the line VOLUME /var/lib/docker in the Dockerfile, in order to persist docker state (image, build cache, etc...) inside the container but it is causing issues.

Error response from daemon: failed to create task for container: failed to start shim: mkdir /var/run/docker/containerd/daemon/io.containerd.runtime.v2.task/moby/6e1d6898d0a6bc7df4e0e1db4ed5b5014a7aea275c397997ba99c421d3570d5e: file exists: unknown

When running docker compose up inside, after a commit and restart of a container with saved docker state.

I'm using Ubuntu 22.04 both host, container and sub-containers.

Any idea of the root cause?

BTW, thanks a lot for the project, very useful to have an Ubuntu based dind!

sami-sweng commented 4 months ago

Note: I thought it could have been caused by docker data corruption when the container shuts down so I tried to gracefully shutdown the container before committing, using:

pids=$(pgrep supervisord)
kill $pids
sleep 10

but without success.

sami-sweng commented 4 months ago

Other note, The first tentative is meant to fail (thank you @greut) and as discussed here My second tentative with a volume kept consistent across restarts cause the exact same issue so overlayfs-over-overlayfs might not be the root cause of the above.

cruizba commented 3 months ago

Hello @sami-sweng, sorry for the delay.

You should be able to persist images, build, etc, just by executing the container like this:

docker run -it -v $(pwd)/var-lib-docker:/var/lib/docker --privileged cruizba/ubuntu-dind
sami-sweng commented 3 months ago

Hey @cruizba,

no problem and thank you for the answer.

Unfortunately I have the same issue after committing and reusing the same volume:

Error response from daemon: failed to create task for container: failed to start shim: mkdir /var/run/docker/containerd/daemon/io.containerd.runtime.v2.task/moby/3c3c58346fb0104c8b8ad7031811ecea657a738348b1415bb035a163afacb7cb: file exists: unknown

Maybe it's an issue with my setup only..? (Ubuntu 22.04, docker 24.0.6 host, 26.0.0 inside) Are you able to commit a container and restart it without issue?

cruizba commented 3 months ago

Ah, are you committing?

I think that's not possible unfortunately :(

If your purpose is to store images inside another image, it is not possible AFAIK.

sami-sweng commented 3 months ago

Ah, I see thank you...

Yes I commit as doing the setup in a dockerfile is not possible either...

Do you know why it's not possible?

Is there a way to keep the state of the container while also keeping the image cache and not having to download them all each time?