Pinning Docker Images to IPFS

Learn how to pin Docker images to IPFS.

What is IPDR?

IPDR is a Docker Registry tool that publishes Docker images to IPFS, allowing for a decentralized alternative to a central registry like Docker Hub. Once uploaded to IPFS, the docker image must be pinned to persist on IPFS long-term.

Read below to learn how to pin Docker images to IPFS with Filebase.

Prerequisites:

1. Clone the ipdr GitHub repository:

wget https://github.com/ipdr/ipdr/releases/download/v0.1.7/ipdr_0.1.7_darwin_arm64.tar.gz

tar -xvzf ipdr_0.1.7_darwin_arm64.tar.gz ipdr

Test the installation with the following command:

./ipdr --help

2. Then, move to the bin path:

sudo mv ipdr /usr/local/bin/ipdr

3. Open a new command prompt and start the IPFS daemon with the following command:

ipfs daemon

4. Then, add docker.local to /etc/hosts:

echo '127.0.0.1 docker.local' | sudo tee -a /etc/hosts

echo '::1 docker.local' | sudo tee -a /etc/hosts

5. Create a new file called Dockerfile that contains the following text:

FROM busybox:latest

CMD echo 'hello world'

6. Build the Docker image with the command:

docker build -t example/helloworld .

7. Then, run the Docker container to test its functionality:

docker run example/helloworld:latest

If successful, the terminal window will echo ‘hello world’.

8. Next, use IPDR to push your Docker container to IPFS:

ipdr push example/helloworld

You will receive output resembling the following:

INFO[0000] [registry] temp: /var/folders/k1/mmftgd4pj0xf9csdb2r8q9700000gn/T/205139235
INFO[0000] [registry] preparing image in: /var/folders/k1/mmftgd4pj0xf9csdb2r8q9700000gn/T/657143846
INFO[0000]
[registry] dist: /var/folders/k1/mmftgd4pj0xf9csdb2r8q9700000gn/T/657143846/default/blobs/sha256:305510b2c684403553fd8f383e8d109b147df2cfde60e40a85564532c383c8b8
INFO[0000] [registry] compressing layer: /var/folders/k1/mmftgd4pj0xf9csdb2r8q9700000gn/T/205139235/886f4bdfa483cc176e947c63d069579785c051793a9634f571fded7b9026cd3c/layer.tar
INFO[0000] [registry] root dir: /var/folders/k1/mmftgd4pj0xf9csdb2r8q9700000gn/T/657143846
INFO[0000] [registry] upload hash QmbaJQAZ76ngXHGp4oGg5PFKVyUMKbMC2sCvnVRG6awDcn
INFO[0000]
[registry] uploaded to /ipfs/QmbaJQAZ76ngXHGp4oGg5PFKVyUMKbMC2sCvnVRG6awDcn
INFO[0000] [registry] docker image ciqmw4mig2uwcxvetsjp2mjdde27wiaygddjlutoywq43udutvdmuxk

Successfully pushed Docker image to IPFS:
/ipfs/QmbaJQAZ76ngXHGp4oGg5PFKVyUMKbMC2sCvnVRG6awDcn

9. Then, navigate to the Filebase web console dashboard. Select the Buckets option from the side bar menu, then select an IPFS bucket or create a new IPFS bucket.

10. Select ‘Upload’ in the upper right corner.

11. Then select ‘CID’:

12. Input the CID returned from the command line and provide a file name to be associated with the CID:

13. Once added, the file will be listed in your bucket:

Last updated