Build Cosmos Docker and upload to Docker-Hub for run in any machine


#1

#If need install docker and Goland :wink: Start here.
#Install go

wget -c 'https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz' -O go1.10.3.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz
sudo rm -Rf go1.10.3.linux-amd64.tar.gz

#Set gopath

 vi $HOME/.profile

#Add this lines to your file:
PATH="$PATH:/usr/local/go/bin"
GOPATH="$HOME/go"
PATH="$PATH:$GOROOT/bin:$GOPATH/bin"

#reload profile

source $HOME/.profile
go version

#$: go version go1.10.3 linux/amd64

Step 2

#Install Docker

 sudo apt-get update
 curl -fsSL get.docker.com -o get-docker.sh
 sh get-docker.sh
 sh install.sh

#Add your user to Docker Group

 sudo usermod -aG docker $(whoami)

#Now that Goland and Docker is installed, just Download Cosmos Official repo.

go get github.com/cosmos/cosmos-sdk

#Open Cosmos Dir

cd go/src/github.com/cosmos/cosmos-sdk

#Build the Docker-Cosmos locally in the server

docker build -t CONTAINER-NAME .
#Example= docker build -t cosmos-026 .

#open a free Docker-Hub account
https://hub.docker.com/

#After opening the account, back to the server

#login in the server with your Docker-ID

docker login

#Tag the image for up to your Docker repo.

docker tag image username/repository:tag

#Ejample = docker tag cosmos-026 meleatrust/get-cosmos:part026

#Now up the Container image to your Docker repos.

docker push Docker-ID/docker-repo:Tag

#To see the container

docker image ls

#Great now you can use docker run and run your Cosmos-repo on any machine no need build again with this command:

CMD#1=

docker run -it -p 26657:26657 -p 26656:26656 -v ~/.gaiad:/root/.gaiad -v ~/.gaiacli:/root/.gaiacli Docker-ID/DockerContainer:TAG gaiad init --name VALIDATORIAN-NAME
#Example= docker run -it -p 26657:26657 -p 26656:26656 -v ~/.gaiad:/root/.gaiad -v ~/.gaiacli:/root/.gaiacli meleatrust/get-cosmos:part026 gaiad init --name VALIDATORIAN-NAME

#Lets add the seed and the persistent peer for Sync gaia-8001

cd .gaiad/data

#If -bash: cd: data: Permission denied =

sudo chown user:group data

#Remove default genesis file and down the good for gaia-8001. (today)

rm genesis.json

Download the Good genesis.json

wget -c 'https://raw.githubusercontent.com/cosmos/testnets/master/gaia-8001/genesis.json '

#Add seed nodes and persistent peers to config.toml and verify your Validatorian name is ok.

vi config.toml
seeds = "7c8b8fd03577cd4817f5be1f03d506f879df98d8@gaia-seed1.interblock.io:26656, a28737ff02391a6e00a1d3b79befd57e68e8264c@gaia-seed2.interblock.io:26656, 987ffd26640cd03d08ed7e53b24dfaa7956e612d@gaia-seed3.interblock.io:26656,837ab35ee80e6882da08ab6244ef27538e73aedd@gaia-seed4.interblock.io:26656"

#Start Cosmos-Docker
CMD#2=

docker run -it -p 26657:26657 -p 26656:26656 -v ~/.gaiad:/root/.gaiad -v ~/.gaiacli:/root/.gaiacli Docker-ID/DockerContainer:TAG gaiad start

#Ok here is running the Cosmos Gaia-8001, Salut!

Summary CMD

Start cosmos docker

docker run -it -p 26657:26657 -p 26656:26656 -v ~/.gaiad:/root/.gaiad -v ~/.gaiacli:/root/.gaiacli Docker-ID/DockerContainer:TAG gaiad start
cd .gaiad/data

#If -bash: cd: data: Permission denied = sudo chown user:group data

#Add seed nodes and persistent peers to config.toml and verify your Validatorian name is ok.

vi config.toml

Start Cosmos Docker

docker run -it -p 26657:26657 -p 26656:26656 -v ~/.gaiad:/root/.gaiad -v ~/.gaiacli:/root/.gaiacli Docker-ID/DockerContainer:TAG gaiad start

#for close gaia

CRTL+C

#for run in Detached mode

docker run -it -d -p 26657:26657 -p 26656:26656 -v ~/.gaiad:/root/.gaiad -v ~/.gaiacli:/root/.gaiacli gaia gaiad start

#For stop the gaia in detached mode

docker container ls
docker stop (CONTAINER ID from your repo.)

Here one Back up file and instructions for sync the block +900k

Enjoy, more docker cmd comings later

:slight_smile: post under constructions but verify for now is working ok. just need to add more cmd.
cheers :hugs:

Here two more Docker-Cosmos Post:

Happy dockerization