Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
201 lines (141 sloc) 6.23 KB

Run in docker

Simple and fast setup of EOS.IO on Docker is also available.

Install Dependencies

Docker Requirement

  • At least 7GB RAM (Docker -> Preferences -> Advanced -> Memory -> 7GB or above)
  • If the build below fails, make sure you've adjusted Docker Memory settings and try again.

Build eos image

git clone https://github.com/EOSIO/eos.git --recursive  --depth 1
cd eos/Docker
docker build . -t eosio/eos

The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.3.2 tag, you could do the following:

docker build -t eosio/eos:v1.3.2 --build-arg branch=v1.3.2 .

By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image.

docker build -t eosio/eos --build-arg symbol=<symbol> .

Start nodeos docker container only

docker run --name nodeos -p 8888:8888 -p 9876:9876 -t eosio/eos nodeosd.sh -e --http-alias=nodeos:8888 --http-alias=127.0.0.1:8888 --http-alias=localhost:8888 arg1 arg2

By default, all data is persisted in a docker volume. It can be deleted if the data is outdated or corrupted:

$ docker inspect --format '{{ range .Mounts }}{{ .Name }} {{ end }}' nodeos
fdc265730a4f697346fa8b078c176e315b959e79365fc9cbd11f090ea0cb5cbc
$ docker volume rm fdc265730a4f697346fa8b078c176e315b959e79365fc9cbd11f090ea0cb5cbc

Alternately, you can directly mount host directory into the container

docker run --name nodeos -v /path-to-data-dir:/opt/eosio/bin/data-dir -p 8888:8888 -p 9876:9876 -t eosio/eos nodeosd.sh -e --http-alias=nodeos:8888 --http-alias=127.0.0.1:8888 --http-alias=localhost:8888 arg1 arg2

Get chain info

curl http://127.0.0.1:8888/v1/chain/get_info

Start both nodeos and keosd containers

docker volume create --name=nodeos-data-volume
docker volume create --name=keosd-data-volume
docker-compose up -d

After docker-compose up -d, two services named nodeosd and keosd will be started. nodeos service would expose ports 8888 and 9876 to the host. keosd service does not expose any port to the host, it is only accessible to cleos when running cleos is running inside the keosd container as described in "Execute cleos commands" section.

Execute cleos commands

You can run the cleos commands via a bash alias.

alias cleos='docker-compose exec keosd /opt/eosio/bin/cleos -u http://nodeosd:8888 --wallet-url http://localhost:8900'
cleos get info
cleos get account inita

Upload sample exchange contract

cleos set contract exchange contracts/exchange/

If you don't need keosd afterwards, you can stop the keosd service using

docker-compose stop keosd

Develop/Build custom contracts

Due to the fact that the eosio/eos image does not contain the required dependencies for contract development (this is by design, to keep the image size small), you will need to utilize the eosio/eos-dev image. This image contains both the required binaries and dependencies to build contracts using eosiocpp.

You can either use the image available on Docker Hub or navigate into the dev folder and build the image manually.

cd dev
docker build -t eosio/eos-dev .

Change default configuration

You can use docker compose override file to change the default configurations. For example, create an alternate config file config2.ini and a docker-compose.override.yml with the following content.

version: "2"

services:
  nodeos:
    volumes:
      - nodeos-data-volume:/opt/eosio/bin/data-dir
      - ./config2.ini:/opt/eosio/bin/data-dir/config.ini

Then restart your docker containers as follows:

docker-compose down
docker-compose up

Clear data-dir

The data volume created by docker-compose can be deleted as follows:

docker volume rm nodeos-data-volume
docker volume rm keosd-data-volume

Docker Hub

Docker Hub image available from docker hub. Create a new docker-compose.yaml file with the content below

version: "3"

services:
  nodeosd:
    image: eosio/eos:latest
    command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e --http-alias=nodeosd:8888 --http-alias=127.0.0.1:8888 --http-alias=localhost:8888
    hostname: nodeosd
    ports:
      - 8888:8888
      - 9876:9876
    expose:
      - "8888"
    volumes:
      - nodeos-data-volume:/opt/eosio/bin/data-dir

  keosd:
    image: eosio/eos:latest
    command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900 --http-alias=localhost:8900 --http-alias=keosd:8900
    hostname: keosd
    links:
      - nodeosd
    volumes:
      - keosd-data-volume:/opt/eosio/bin/data-dir

volumes:
  nodeos-data-volume:
  keosd-data-volume:

NOTE: the default version is the latest, you can change it to what you want

run docker pull eosio/eos:latest

run docker-compose up

EOSIO Testnet

We can easily set up a EOSIO local testnet using docker images. Just run the following commands:

Note: if you want to use the mongo db plugin, you have to enable it in your data-dir/config.ini first.

# create volume
docker volume create --name=nodeos-data-volume
docker volume create --name=keosd-data-volume
# pull images and start containers
docker-compose -f docker-compose-eosio-latest.yaml up -d
# get chain info
curl http://127.0.0.1:8888/v1/chain/get_info
# get logs
docker-compose logs -f nodeosd
# stop containers
docker-compose -f docker-compose-eosio-latest.yaml down

The blocks data are stored under --data-dir by default, and the wallet files are stored under --wallet-dir by default, of course you can change these as you want.

About MongoDB Plugin

Currently, the mongodb plugin is disabled in config.ini by default, you have to change it manually in config.ini or you can mount a config.ini file to /opt/eosio/bin/data-dir/config.ini in the docker-compose file.