Note: If you're looking for instructions on building regular docker containers, you're in the wrong place. These instructions are for udocker, not actual Docker or rootless docker.
udocker is a tool that lets you run simple Docker containers in userspace without requiring root privileges or user namespaces. However, it doesn't support building Dockerfiles, which makes bringing in new container images difficult. I managed to replicate that functionality using kaniko and skopeo.
Note that this method is quite hacky and has some issues:
docker.io/
prepended to it by skopeo. While it's correct, it is somewhat annoying.Set the image name in an environment variable that can be reused later:
IMAGE_NAME=mattx/my-alpine
Create a directory and copy your build context and Dockerfile into it. For example:
Run the build:
Kaniko outputs OCI images that won't work in udocker. To get around this, convert the image using skopeo:
Should you want it, you can remove intermediate.tar
as it is no longer needed.
To load the image, run:
You can now try running the image with udocker:
You might need to use docker.io/library/$IMAGE_NAME
if you didn't use an username in IMAGE_NAME
.