README.md 2.8 KB
Newer Older
S
Sandwich 已提交
1
# Run in docker
N
Nathan Hourt 已提交
2

K
Kevin Heifner 已提交
3
Simple and fast setup of EOS.IO on Docker is also available.
S
Sandwich 已提交
4 5

## Install Dependencies
H
Huang-Ming Huang 已提交
6
 - [Docker](https://docs.docker.com) Docker 17.05 or higher is required
N
noprom 已提交
7
 - [docker-compose](https://docs.docker.com/compose/) version >= 1.10.0
peterwillcn's avatar
peterwillcn 已提交
8

A
Andrianto Lie 已提交
9 10
## Docker Requirement
 - At least 8GB RAM (Docker -> Preferences -> Advanced -> Memory -> 8GB or above)
N
noprom 已提交
11

S
Sandwich 已提交
12
## Build eos image
peterwillcn's avatar
peterwillcn 已提交
13

S
Sandwich 已提交
14
```bash
peterwillcn's avatar
peterwillcn 已提交
15
git clone https://github.com/EOSIO/eos.git --recursive
H
Huang-Ming Huang 已提交
16 17
cd eos/Docker
docker build . -t eosio/eos
peterwillcn's avatar
peterwillcn 已提交
18 19
```

20
## Start nodeos docker container only
peterwillcn's avatar
peterwillcn 已提交
21

S
Sandwich 已提交
22
```bash
peterwillcn's avatar
peterwillcn 已提交
23
docker run --name nodeos -p 8888:8888 -p 9876:9876 -t eosio/eos nodeosd.sh arg1 arg2
peterwillcn's avatar
peterwillcn 已提交
24
```
S
Sandwich 已提交
25

H
Huang-Ming Huang 已提交
26 27
By default, all data is persisted in a docker volume. It can be deleted if the data is outdated or corrupted:
``` bash
28
$ docker inspect --format '{{ range .Mounts }}{{ .Name }} {{ end }}' nodeos
H
Huang-Ming Huang 已提交
29 30 31
fdc265730a4f697346fa8b078c176e315b959e79365fc9cbd11f090ea0cb5cbc
$ docker volume rm fdc265730a4f697346fa8b078c176e315b959e79365fc9cbd11f090ea0cb5cbc
```
H
Huang-Ming Huang 已提交
32

H
Huang-Ming Huang 已提交
33
Alternately, you can directly mount host directory into the container
H
Huang-Ming Huang 已提交
34
```bash
peterwillcn's avatar
peterwillcn 已提交
35
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 arg1 arg2
H
Huang-Ming Huang 已提交
36 37
```

S
Sandwich 已提交
38 39 40
## Get chain info

```bash
peterwillcn's avatar
peterwillcn 已提交
41
curl http://127.0.0.1:8888/v1/chain/get_info
peterwillcn's avatar
peterwillcn 已提交
42 43
```

44
## Start both nodeos and walletd containers
H
Huang-Ming Huang 已提交
45 46

```bash
N
noprom 已提交
47 48 49
docker volume create --name=nodeos-data-volume
docker volume create --name=walletd-data-volume
docker-compose up -d
H
Huang-Ming Huang 已提交
50 51
```

N
noprom 已提交
52
After `docker-compose up -d`, two services named nodeos and walletd will be started. nodeos service would expose ports 8888 and 9876 to the host. walletd service does not expose any port to the host, it is only accessible to cleos when runing cleos is running inside the walletd container as described in "Execute cleos commands" section.
H
Huang-Ming Huang 已提交
53 54


55
### Execute cleos commands
peterwillcn's avatar
peterwillcn 已提交
56

57
You can run the `cleos` commands via a bash alias.
S
Sandwich 已提交
58 59

```bash
N
noprom 已提交
60
alias cleos='docker-compose exec walletd /opt/eosio/bin/cleos -H nodeosd'
61 62
cleos get info
cleos get account inita
peterwillcn's avatar
peterwillcn 已提交
63 64
```

H
Huang-Ming Huang 已提交
65 66
Upload sample exchange contract

S
Sandwich 已提交
67
```bash
68
cleos set contract exchange contracts/exchange/exchange.wast contracts/exchange/exchange.abi
peterwillcn's avatar
peterwillcn 已提交
69 70
```

H
Huang-Ming Huang 已提交
71
If you don't need walletd afterwards, you can stop the walletd service using
S
Sandwich 已提交
72 73

```bash
H
Huang-Ming Huang 已提交
74 75
docker-compose stop walletd
```
H
Huang-Ming Huang 已提交
76
### Change default configuration
H
Huang-Ming Huang 已提交
77 78 79 80 81 82 83

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.

```yaml
version: "2"

services:
84
  nodeos:
H
Huang-Ming Huang 已提交
85
    volumes:
86
      - nodeos-data-volume:/opt/eosio/bin/data-dir
K
Kevin Heifner 已提交
87
      - ./config2.ini:/opt/eosio/bin/data-dir/config.ini
S
Sandwich 已提交
88 89
```

H
Huang-Ming Huang 已提交
90
Then restart your docker containers as follows:
S
Sandwich 已提交
91 92

```bash
H
Huang-Ming Huang 已提交
93 94 95
docker-compose down
docker-compose up
```
H
Huang-Ming Huang 已提交
96 97 98 99 100

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

```bash
101
docker volume rm docker_nodeos-data-volume
H
Huang-Ming Huang 已提交
102
```