Expanding the default docker image size on Jetson Xavier

I’m putting together a docker image build on a Jetson Xavier, but I’ve been running into space issues after only a few apt-gets. The SD card I’m using has 128 GB of space available, but for some reason my docker /dev/root and overlay file systems are restricted to 22 GB, and fill up fast.

I’ve been looking for a way to expand the default storage available to a docker image.

When I run “df -H”, on a fresh container, I get the following:

Filesystem       Size  Used Avail Use% Mounted on
overlay           22G   17G  3.8G  82% /
tmpfs             68M     0   68M   0% /dev
tmpfs            4.1G     0  4.1G   0% /sys/fs/cgroup
shm               68M     0   68M   0% /dev/shm
/dev/mmcblk0p12  104G   13G   87G  13% /mnt
/dev/root         22G   17G  3.8G  82% /etc/hosts
tmpfs            4.1G     0  4.1G   0% /etc/nvidia/nvidia-application-profiles-rc.d
devtmpfs         3.7G     0  3.7G   0% /dev/fb0
tmpfs            4.1G     0  4.1G   0% /proc/asound
tmpfs            4.1G     0  4.1G   0% /sys/firmware

I’m using overlay2, which should resize according to the system requirements, but so far it has not.

The devicemapper options in the docker documentation here seemed promising, but I couldn’t get any of them to work.

Any help would be much appreciated!

I found a solution! I just had to change docker’s data-root to be somewhere on the SD card! For anyone stuck on this in the future, here’s the process:

First I made a new directory on the SD card

$ mkdir Docker
$ cd Docker

And copied it’s path. Then I stopped docker via

$ sudo systemctl stop docker

Next, I took a look at docker’s daemon.json file. You can run the following to see it’s contents:

$ cat /etc/docker/daemon.json

If the file does not exist, you will see a message such as:

cat: /etc/docker/daemon.json: No such file or directory

If it does exist, you will see the contents, which will be something like:

{
    “runtimes”: {
        “nvidia”: {
            “path”: “nvidia-container-runtime”,
            “runtimeArgs”: []
        }
    }
}

We want to add a line to this file, and can do so via the following terminal command:

$ sudo gedit /etc/docker/daemon.json

This will open the daemon.json file in the gedit editor. We want to add the following line:

{
    “runtimes”: {
        “nvidia”: {
            “path”: “nvidia-container-runtime”,
            “runtimeArgs”: []
        }
    },
    “data-root”: “/home/user/Docker”
}

Your “/home/user/Docker” is the full directory path name you copied from earlier. This will change the root directory of our docker daemon to our SD card, instead of keeping it in local storage on the board.

On the off chance your board does not have a daemon.json file, you can create one via the following commands:

$ sudo -i
# cat > /etc/docker/daemon.json
# exit

The first command starts a root user terminal, which can be identified by the # command symbol. Then we use cat to create the file, and exit the root terminal via exit.

Then we can open the file as before with:

$ sudo gedit /etc/docker/daemon.json

And fill it with the following code:

{
    “data-root”: “/home/user/Docker”
}

Now that my daemon.json file had been changed, I ran the following commands to restart docker:

$ sudo systemctl start docker

And there we have it! If you run:

$ sudo docker info

You should see info and no errors. Now you can carry on as in the previous sections without worrying about running out of space for your build.

Nice! Thanks for your sharing!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.