Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 9d095ee

Browse files
ctalledorodnymolina
authored andcommitted
Updated text regarding persistence of inner docker images.
1 parent 45395c1 commit 9d095ee

File tree

3 files changed

+95
-30
lines changed

3 files changed

+95
-30
lines changed

docs/distro-compat.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
## Supported Linux Distros
99

10-
Sysbox relies on functionality that is currently only present in Ubuntu Linux
11-
and as a result Ubuntu is the only distro supported at this time. We are working
10+
Sysbox relies on functionality that is currently only present in Ubuntu Linux.
11+
As a result Ubuntu is the only distro supported at this time. We are working
1212
on adding support for more distros.
1313

1414
## Ubuntu Support

docs/quickstart/dind.md

Lines changed: 91 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -299,25 +299,28 @@ It's possible to override this behavior by mounting host storage into
299299
the system container's `/var/lib/docker` in order to persist the
300300
inner Docker's image cache across system container life-cycles.
301301

302-
To do this, follow these steps:
302+
In fact, not only do inner Docker images persist; inner containers will also
303+
persist (thought they will need to be restarted).
304+
305+
Here is an example:
303306

304307
1) Create a Docker volume on the host to serve as the persistent image cache for
305308
the Docker daemon inside the system container.
306309

307310
```console
308-
$ docker volume create my-image-cache
309-
my-image-cache
311+
$ docker volume create myvol
312+
myvol
310313

311314
$ docker volume list
312315
DRIVER VOLUME NAME
313-
local my-image-cache
316+
local myvol
314317
```
315318

316319
2) Launch the system container and mount the volume into the system
317320
container's `/var/lib/docker` directory.
318321

319322
```console
320-
$ docker run --runtime=sysbox-runc -it --rm --hostname syscont --mount source=my-image-cache,target=/var/lib/docker nestybox/alpine-docker
323+
$ docker run --runtime=sysbox-runc -it --rm --hostname syscont --mount source=myvol,target=/var/lib/docker nestybox/alpine-docker
321324
/ #
322325
```
323326

@@ -342,45 +345,93 @@ REPOSITORY TAG IMAGE ID CREATED
342345
busybox latest 19485c79a9bb 7 weeks ago 1.22MB
343346
```
344347

345-
5) Exit the system container. Since it was started with the `--rm`
346-
option, Docker will remove the system container from the system.
347-
However, the contents of the system container's `/var/lib/docker`
348-
will persist since they are stored in volume `my-image-cache`.
348+
5) Create an inner container:
349+
350+
```console
351+
/ # docker run -d --name inner-container busybox tail -f /dev/null
352+
56ccb4bb33280f3f670956f6f06afde08e8219eb56c9d79a8b0e5d925ecee96d
353+
354+
/ # docker ps
355+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
356+
56ccb4bb3328 busybox "tail -f /dev/null" 4 seconds ago Up 2 seconds inner-container
357+
```
358+
359+
6) Exit the system container.
360+
361+
This causes the inner container to be automatically stopped.
349362

350-
6) Start a new system container and mount the `my-image-cache` volume:
363+
The contents of the system container's `/var/lib/docker` will persist since they
364+
are stored in volume `myvol`.
365+
366+
7) Start a new system container and mount `myvol` into it:
351367

352368
```console
353-
$ docker run --runtime=sysbox-runc -it --rm --hostname syscont --mount source=my-image-cache,target=/var/lib/docker nestybox/alpine-docker
369+
$ docker run --runtime=sysbox-runc -it --rm --hostname syscont --mount source=myvol,target=/var/lib/docker nestybox/alpine-docker
370+
```
354371

372+
8) Start Docker inside:
373+
374+
```console
355375
/ # dockerd > /var/log/dockerd.log 2>&1 &
376+
```
377+
378+
9) Verify that the inner Docker images persisted:
356379

380+
```console
357381
/ # docker image ls
358382
REPOSITORY TAG IMAGE ID CREATED SIZE
359383
busybox latest 19485c79a9bb 7 weeks ago 1.22MB
360384
```
361385

362-
As shown, the inner container images persist across the life-cycle of
363-
the system container.
386+
There they are!
387+
388+
10) Verify that the inner Docker container persisted:
389+
390+
```console
391+
/ # docker ps -a
392+
393+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
394+
56ccb4bb3328 busybox "tail -f /dev/null" 32 seconds ago Exited (255) 3 seconds ago inner-container
395+
396+
/ # docker start inner-container
397+
inner-container
398+
/ # docker ps -a
399+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
400+
56ccb4bb3328 busybox "tail -f /dev/null" 42 seconds ago Up 1 second inner-container
401+
```
402+
403+
There is it is!
404+
405+
As shown, the inner container images and even inner containers persisted across
406+
the life-cycle of the system container.
364407

365408
This is cool because it means that a system container can leverage an existing
366409
Docker image cache stored somewhere on the host, thus avoiding having to pull
367410
those inner Docker images from the network each time a new system container is
368411
started.
369412

370-
There are a couple of caveats to keep in mind:
413+
There is a couple of important caveat to keep in mind:
414+
415+
- A Docker volume mounted into the system container's `/var/lib/docker` must
416+
only be mounted on a **single system container at any given time**. This is
417+
a restriction imposed by the Docker daemon, which does not allow its image
418+
cache to be shared concurrently among multiple daemon instances. Sysbox will
419+
check for violations of this rule and report an appropriate error during
420+
system container creation.
371421

372-
- A persistent Docker image cache must only be mounted on a **single
373-
system container at any given time**. This is a restriction imposed
374-
by the Docker daemon, which does not allow its image cache to be
375-
shared concurrently among multiple daemon instances. Sysbox will
376-
check for violations of this rule and report an appropriate error
377-
during system container creation.
422+
- A Docker volume mounted into the system container's `/var/lib/docker`
423+
will **inherit** any files present in that same directory as part of the system
424+
container's image. Such files would be present when using system containers
425+
that have preloaded inner container images.
378426

379-
- A persistent Docker image cache mounted into the system container's
380-
`/var/lib/docker` directory will "mask" any files present in that same
381-
directory as part of the system container's image. Such files would be
382-
present when using system containers that have preloaded inner container
383-
images.
427+
- In other words, if the system container comes preloaded with inner images,
428+
those will be automatically transferred to the Docker volume when the
429+
system container starts, and will persist across the system container
430+
life-cycle.
431+
432+
- Note that this behavior is different than when bind-mounting host
433+
directories into the system container `/var/lib/docker` (see next
434+
section).
384435

385436
## Persistence of Inner Container Images using Bind Mounts
386437

@@ -455,6 +506,19 @@ REPOSITORY TAG IMAGE ID CREATED
455506
busybox latest 19485c79a9bb 7 weeks ago 1.22MB
456507
```
457508

458-
```
509+
There are a couple of caveats to keep in mind here:
459510

460-
```
511+
- A host directory bind-mounted into the system container's `/var/lib/docker` must
512+
only be mounted on a **single system container at any given time**. This is
513+
a restriction imposed by the Docker daemon, which does not allow its image
514+
cache to be shared concurrently among multiple daemon instances. Sysbox will
515+
check for violations of this rule and report an appropriate error during
516+
system container creation.
517+
518+
- A host directory bind-mounted into the system container's `/var/lib/docker`
519+
will "mask" any files present in that same directory as part of the system
520+
container's image. Such files would be present when using system containers
521+
that have preloaded inner container images.
522+
523+
- This behavior differs from when Docker volume mounts are mounted into
524+
the system container's `/var/lib/docker` (see prior section).

docs/user-guide/dind.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ However, inner container images that are pulled into the system container at
7878
runtime are not by default persistent: they get destroyed when the system
7979
container is removed (e.g., via `docker rm`).
8080

81-
But it's easy to make these runtime inner container images persistent too.
81+
But it's easy to make these runtime inner container images (and even inner
82+
containers) persistent too.
8283

8384
You do this by simply mounting a host directory into the system container's
8485
`/var/lib/docker` directory (i.e., where the inner Docker stores its container

0 commit comments

Comments
 (0)