Search…
How to run a local network

Prerequisites

You must install Docker. Install docker-compose as well if it is not installed with Docker by default

Clone the gochain-local repo

Use the convenience scripts in the gochain-local repository to run a local ICON network. Here is a brief summary.
1
$ git clone [email protected]:icon-project/gochain-local.git
Copied!

Using Docker

Build the Docker image

1
# Build the image
2
$ git clone [email protected]:icon-project/goloop.git
3
$ cd goloop
4
$ make gochain-icon-image
5
6
# Verify the image
7
$ docker images goloop/gochain-icon
8
REPOSITORY TAG IMAGE ID CREATED SIZE
9
goloop/gochain-icon latest 74676aec69ef 2 minutes ago 513MB
Copied!

Use the convenience script

1
# Go to the gochain-local directory
2
$ ./run_gochain.sh
3
Usage: ./run_gochain.sh [start|stop|pause|unpause] (docker-tag)
Copied!

Start the container

1
$ ./run_gochain.sh start
2
>>> START iconee 9082 latest
3
48e4c66fec68d01e767da91cbbb043c03f595b33cac69c8cdf94f39eaa03b34e
4
5
$ docker ps
6
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7
48e4c66fec68 goloop/gochain-icon:latest "/entrypoint /bin/sh…" 9 seconds ago Up 8 seconds 8080/tcp, 9080/tcp, 0.0.0.0:9082->9082/tcp gochain-iconee
Copied!
Note that log messages will be generated at ./chain/iconee.log.
1
$ head ./chain/iconee.log
2
I|20211008-03:27:35.242715|b6b5|-|main|main.go:433 ____ ___ ____ _ _ _ ___ _ _
3
I|20211008-03:27:35.243626|b6b5|-|main|main.go:433 / ___|/ _ \ / ___| | | | / \ |_ _| \ | |
4
I|20211008-03:27:35.243644|b6b5|-|main|main.go:433 | | _| | | | | | |_| | / _ \ | || \| |
5
I|20211008-03:27:35.243659|b6b5|-|main|main.go:433 | |_| | |_| | |___| _ |/ ___ \ | || |\ |
6
I|20211008-03:27:35.243678|b6b5|-|main|main.go:433 \____|\___/ \____|_| |_/_/ \_\___|_| \_|
7
I|20211008-03:27:35.243693|b6b5|-|main|main.go:435 Version : v1.0.0
8
I|20211008-03:27:35.243713|b6b5|-|main|main.go:436 Build : linux/amd64 tags(rocksdb)-2021-10-05-08:13:18
9
I|20211008-03:27:35.243732|b6b5|-|metric|metric.go:150 Initialize rootMetricCtx
10
T|20211008-03:27:35.244757|b6b5|-|TP|transport.go:383 registerPeerHandler &{0xc0001ca540 0xc0001ca4e0 map[] {{0 0} 0 0 0 0} 0xc0001ca5a0} true
11
T|20211008-03:27:35.244925|b6b5|-|TP|transport.go:383 registerPeerHandler &{0xc0001ca4b0 :8080} true
Copied!

Stop the container

1
$ ./run_gochain.sh stop
2
>>> STOP gochain-iconee
3
gochain-iconee
4
gochain-iconee
Copied!

Pause the container

1
$ ./run_gochain.sh pause
Copied!

Unpause the container

1
$ ./run_gochain.sh unpause
Copied!

Using docker-compose

Create and Start the container

1
$ docker-compose up -d
2
[+] Running 2/2
3
⠿ Network gochain-local_default Created
4
⠿ Container gochain-iconee Started
5
6
$ docker ps
7
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8
48e4c66fec68 goloop/gochain-icon:latest "/entrypoint /bin/sh…" 9 seconds ago Up 8 seconds 8080/tcp, 9080/tcp, 0.0.0.0:9082->9082/tcp gochain-iconee
Copied!

Check logs

1
$docker-compose logs -f
Copied!

Stop the container

1
$docker-compose stop
Copied!

Stop and remove the container

1
$docker-compose down
Copied!

Pause the container

This will pause the local blockchain. No new blocks will be produced.
1
$docker-compose pause
Copied!

Unpause the container

This will resume the blockchain from the same paused height.
1
$docker-compose unpause
Copied!

Persistence of Data

If you want to persist your data across docker restarts, set GOCHAIN_CLEAN_DATA in ./data/dockerenv/iconee to false.

Further resources

The IconLoop Docker Hub organization contains useful Docker images related to the ICON project.