@kyanny's blog

My thoughts, my life. Views/opinions are my own.

How to create an arbitrary large size Docker image

Create a random binary data.

# 2GB data
dd if=/dev/urandom of=blob bs=1m count=2000


FROM ubuntu
COPY blob .

Build a Docker image.

docker build . -t myblob

Check the image size.

❯ docker images | grep myblob
REPOSITORY                                                            TAG       IMAGE ID       CREATED         SIZE
myblob                                                                latest    371aad860d44   2 minutes ago   2.17GB

Publish to GitHub Container registry

Working with the Container registry - GitHub Docs

Login to the Container registry.

echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin

Tag the docker image.

  • OWNER is username/repo
docker tag myblob ghcr.io/OWNER/IMAGE_NAME:latest

Or build a Docker image with tagging.

docker build . -t ghcr.io/OWNER/IMAGE_NAME:latest

Push the docker image.

docker push ghcr.io/OWNER/IMAGE_NAME:latest