├── .gitignore ├── logo.png ├── ddocker └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viraja1/decentralized_docker_hub/HEAD/logo.png -------------------------------------------------------------------------------- /ddocker: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | COMMAND_NAME=$1 4 | IMAGE_NAME=$2 5 | ETH_NETWORK=${3:-mainnet} 6 | GREEN=$'\e[0;32m' 7 | NC=$'\e[0m' 8 | 9 | if [ "$COMMAND_NAME" = "push" ] 10 | then 11 | FILE_NAME=$(sed 's/[^[:alnum:]_]//g' <<< $IMAGE_NAME) 12 | docker save -o /tmp/${FILE_NAME}.tar $IMAGE_NAME 13 | IPFS_OUTPUT=$(pow data stage "/tmp/${FILE_NAME}.tar") 14 | echo -e "\n" 15 | echo $IPFS_OUTPUT 16 | echo -e "\n" 17 | IPFS_HASH=$(echo $IPFS_OUTPUT | grep -oE "Qm[1-9A-HJ-NP-Za-km-z]{44}") 18 | echo -e "IPFS CID:${GREEN} ${IPFS_HASH} ${NC}" 19 | echo -e "\n" 20 | pow config apply -o -w $IPFS_HASH 21 | elif [ "$COMMAND_NAME" = "pull" ] 22 | then 23 | if [[ $IMAGE_NAME == *".eth"* ]]; then 24 | IMAGE_NAME=$(ethereal ens contenthash get --domain=${IMAGE_NAME} --network=${ETH_NETWORK}) 25 | IMAGE_NAME=$(echo $IMAGE_NAME | grep -oE "Qm[1-9A-HJ-NP-Za-km-z]{44}") 26 | echo -e "\n" 27 | echo "IPFS CID: ${GREEN} ${IMAGE_NAME} ${NC}" 28 | echo -e "\n" 29 | fi 30 | pow data get $IMAGE_NAME /tmp/${IMAGE_NAME}.tar 31 | echo -e "\n ${GREEN}" 32 | docker load -i /tmp/${IMAGE_NAME}.tar 33 | echo -e "\n ${NC}" 34 | fi 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Decentralized Docker Hub 2 | 3 | ![](logo.png) 4 | 5 | Using Decentralized Docker Hub, you can easily push and pull docker images 6 | from IPFS and filecoin. It is powered by Powergate. It also has support for ENS domain names. 7 | 8 | ## Demo Video 9 | https://youtu.be/c0AadtIJmYo 10 | 11 | 12 | ## Getting Started 13 | 14 | 1) Install Docker and Docker compose 15 | ``` 16 | https://docs.docker.com/engine/install/#server 17 | https://docs.docker.com/compose/install/ 18 | ``` 19 | 20 | Install Go 1.15 21 | 22 | https://golang.org/dl/ 23 | 24 | Once Go is installed then add the following to ~/.bashrc 25 | 26 | ``` 27 | export GOPATH=$HOME/go 28 | export PATH="$GOPATH/bin:$PATH" 29 | ``` 30 | 31 | Then run the following command 32 | ``` 33 | source ~/.bashrc 34 | ``` 35 | 36 | 2) Run Powergate, Lotus and IPFS containers 37 | 38 | Ensure that make is installed for your OS 39 | 40 | ``` 41 | git clone --depth 1 --branch v1.2.4 https://github.com/textileio/powergate.git 42 | cd powergate 43 | make install-pow 44 | make install-powd 45 | cd docker 46 | BIGSECTORS=true make localnet 47 | ``` 48 | 49 | Replace the last command above with `make up` for using filecoin mainnet instead of localnet 50 | 51 | For hosted powergate instance provided by Textile, you can skip the last step and set POW_SERVERADDRESS env variable. 52 | 53 | 3) Create a Powergate user from a new tab and note down the token from the output 54 | 55 | ``` 56 | pow admin user create 57 | ``` 58 | 59 | For hosted powergate provided by textile, set the following admin token as an env variable before 60 | running the above command (hosted powergate admin APIs are protected using admin token) 61 | ``` 62 | export POW_ADMIN_TOKEN= 63 | ``` 64 | 65 | 4) Add token as the environment variable 66 | 67 | ``` 68 | export POW_TOKEN={token} 69 | ``` 70 | 71 | Replace {token} in the above command with the actual token 72 | 73 | 5) Determine the docker image that you want to push to IPFS and filecoin 74 | 75 | You can either create a new docker image locally or fetch it 76 | from another source 77 | 78 | You can check the list of existing docker images in your local 79 | machine using `docker image ls` 80 | 81 | For this tutorial lets use `alpine` docker image since it is a 82 | lightweight Linux distribution 83 | 84 | 6) Clone Decentralized Docker Hub repo 85 | 86 | ``` 87 | git clone https://github.com/viraja1/decentralized_docker_hub.git 88 | cd decentralized_docker_hub 89 | ``` 90 | 91 | 7) Push alpine image to IPFS and filecoin 92 | 93 | ``` 94 | ./ddocker push alpine 95 | ``` 96 | 97 | Note down the IPFS cid from the output since it will be required 98 | for the next step 99 | 100 | 8) Pull alpine image from IPFS and filecoin 101 | 102 | ``` 103 | ./ddocker pull {cid} 104 | ``` 105 | 106 | Replace {cid} with the IPFS cid noted from the previous step 107 | 108 | 9) Create a test container 109 | ``` 110 | docker container run -it -d alpine 111 | ``` 112 | 113 | ## Pull docker image using ENS domain name 114 | 115 | 1) Install GO (1.15 or above) 116 | 117 | 2) Install Ethereal Command line tool 118 | 119 | Ensure that gcc is installed for your OS before installing ethereal 120 | ``` 121 | GO111MODULE=on go get github.com/wealdtech/ethereal@latest 122 | ``` 123 | 124 | 3) Get the IPFS hash of the docker image and set it as the content hash of your ENS domain 125 | 126 | https://app.ens.domains/ 127 | 128 | 4) Pull docker image from IPFS and filecoin using ENS domain name 129 | 130 | ``` 131 | ./ddocker pull {ens_domain_name} 132 | ``` 133 | 134 | Replace {ens_domain_name} with the actual ENS domain name (defaults to ENS mainnet) 135 | 136 | For ropsten or other testnet, you can specify network at the end 137 | 138 | e.g. 139 | ``` 140 | ./ddocker pull alpine.docker.eth ropsten 141 | ``` 142 | 143 | 144 | ## Filecoin mainnet docker images 145 | https://ipfs.io/ipfs/QmPKru6chbbjxJXWRyNEEY8jmdte2x8ic13bUnrw8Mw7kB/ 146 | 147 | 148 | ## Decentralized Docker Hub Registry 149 | 150 | Decentralized Docker Hub Registry allows you to push and pull docker images from IPFS. 151 | It provides a native docker integration via a custom docker registry server (v2). 152 | It is powered by Textile Hub and Textile Buckets. It also has support for Fleek Space Daemon. 153 | Decentralized Docker Hub Registry has support for encryption and team sharing via Textile Hub. 154 | Custom cron scripts can be written to periodically backup the buckets containing the Docker images to Filecoin. 155 | 156 | https://github.com/viraja1/decentralized_docker_hub_registry --------------------------------------------------------------------------------