README.md 6.0 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
6 7 8

- [Docker](https://docs.docker.com) Docker 17.05 or higher is required
- [docker-compose](https://docs.docker.com/compose/) version >= 1.10.0
peterwillcn's avatar
peterwillcn 已提交
9

A
Andrianto Lie 已提交
10
## Docker Requirement
11

12
- At least 7GB RAM (Docker -> Preferences -> Advanced -> Memory -> 7GB or above)
S
Sterling Ledet 已提交
13
- If the build below fails, make sure you've adjusted Docker Memory settings and try again.
N
noprom 已提交
14

S
Sandwich 已提交
15
## Build eos image
peterwillcn's avatar
peterwillcn 已提交
16

S
Sandwich 已提交
17
```bash
A
Andreas Schlapbach 已提交
18
git clone https://github.com/EOSIO/eos.git --recursive  --depth 1
H
Huang-Ming Huang 已提交
19 20
cd eos/Docker
docker build . -t eosio/eos
peterwillcn's avatar
peterwillcn 已提交
21 22
```

23 24 25 26 27 28
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 dawn-v4.0.0 tag, you could do the following:

```bash
docker build -t eosio/eos:dawn-v4.0.0 --build-arg branch=dawn-v4.0.0 .
```

29 30 31 32 33 34
By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image.

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

35
## Start nodeos docker container only
peterwillcn's avatar
peterwillcn 已提交
36

S
Sandwich 已提交
37
```bash
peterwillcn's avatar
peterwillcn 已提交
38
docker run --name nodeos -p 8888:8888 -p 9876:9876 -t eosio/eos nodeosd.sh arg1 arg2
peterwillcn's avatar
peterwillcn 已提交
39
```
S
Sandwich 已提交
40

H
Huang-Ming Huang 已提交
41
By default, all data is persisted in a docker volume. It can be deleted if the data is outdated or corrupted:
42 43

```bash
44
$ docker inspect --format '{{ range .Mounts }}{{ .Name }} {{ end }}' nodeos
H
Huang-Ming Huang 已提交
45 46 47
fdc265730a4f697346fa8b078c176e315b959e79365fc9cbd11f090ea0cb5cbc
$ docker volume rm fdc265730a4f697346fa8b078c176e315b959e79365fc9cbd11f090ea0cb5cbc
```
H
Huang-Ming Huang 已提交
48

H
Huang-Ming Huang 已提交
49
Alternately, you can directly mount host directory into the container
50

H
Huang-Ming Huang 已提交
51
```bash
peterwillcn's avatar
peterwillcn 已提交
52
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 已提交
53 54
```

S
Sandwich 已提交
55 56 57
## Get chain info

```bash
peterwillcn's avatar
peterwillcn 已提交
58
curl http://127.0.0.1:8888/v1/chain/get_info
peterwillcn's avatar
peterwillcn 已提交
59 60
```

61
## Start both nodeos and keosd containers
H
Huang-Ming Huang 已提交
62 63

```bash
N
noprom 已提交
64
docker volume create --name=nodeos-data-volume
65
docker volume create --name=keosd-data-volume
N
noprom 已提交
66
docker-compose up -d
H
Huang-Ming Huang 已提交
67 68
```

A
Andrianto Lie 已提交
69
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.
H
Huang-Ming Huang 已提交
70

71
### Execute cleos commands
peterwillcn's avatar
peterwillcn 已提交
72

73
You can run the `cleos` commands via a bash alias.
S
Sandwich 已提交
74 75

```bash
E
Eric Iles 已提交
76
alias cleos='docker-compose exec keosd /opt/eosio/bin/cleos -u http://nodeosd:8888 --wallet-url http://localhost:8888'
77 78
cleos get info
cleos get account inita
peterwillcn's avatar
peterwillcn 已提交
79 80
```

H
Huang-Ming Huang 已提交
81 82
Upload sample exchange contract

S
Sandwich 已提交
83
```bash
84
cleos set contract exchange contracts/exchange/exchange.wast contracts/exchange/exchange.abi
peterwillcn's avatar
peterwillcn 已提交
85 86
```

87
If you don't need keosd afterwards, you can stop the keosd service using
S
Sandwich 已提交
88 89

```bash
90
docker-compose stop keosd
H
Huang-Ming Huang 已提交
91
```
92

E
Eric Iles 已提交
93 94
### Develop/Build custom contracts

E
Eric Iles 已提交
95
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.
E
Eric Iles 已提交
96

E
Eric Iles 已提交
97
You can either use the image available on [Docker Hub](https://hub.docker.com/r/eosio/eos-dev/) or navigate into the dev folder and build the image manually.
E
Eric Iles 已提交
98 99

```bash
E
Eric Iles 已提交
100 101
cd dev
docker build -t eosio/eos-dev .
E
Eric Iles 已提交
102 103
```

H
Huang-Ming Huang 已提交
104
### Change default configuration
H
Huang-Ming Huang 已提交
105 106 107 108 109 110 111

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:
112
  nodeos:
H
Huang-Ming Huang 已提交
113
    volumes:
114
      - nodeos-data-volume:/opt/eosio/bin/data-dir
K
Kevin Heifner 已提交
115
      - ./config2.ini:/opt/eosio/bin/data-dir/config.ini
S
Sandwich 已提交
116 117
```

H
Huang-Ming Huang 已提交
118
Then restart your docker containers as follows:
S
Sandwich 已提交
119 120

```bash
H
Huang-Ming Huang 已提交
121 122 123
docker-compose down
docker-compose up
```
H
Huang-Ming Huang 已提交
124 125

### Clear data-dir
126

H
Huang-Ming Huang 已提交
127 128 129
The data volume created by docker-compose can be deleted as follows:

```bash
130 131
docker volume rm nodeos-data-volume
docker volume rm keosd-data-volume
H
Huang-Ming Huang 已提交
132
```
133

K
Kevin Heifner 已提交
134
### Docker Hub
135

K
Kevin Heifner 已提交
136
Docker Hub image available from [docker hub](https://hub.docker.com/r/eosio/eos/).
A
Andrianto Lie 已提交
137
Create a new `docker-compose.yaml` file with the content below
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169

```bash
version: "3"

services:
  nodeosd:
    image: eosio/eos:latest
    command: /opt/eosio/bin/nodeosd.sh
    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
    hostname: keosd
    links:
      - nodeosd
    volumes:
      - keosd-data-volume:/opt/eosio/bin/data-dir

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

```

A
Andrianto Lie 已提交
170
*NOTE:* the default version is the latest, you can change it to what you want
K
kaidiren 已提交
171

172
run `docker pull eosio/eos:latest`
K
kaidiren 已提交
173

174 175
run `docker-compose up`

N
noprom 已提交
176
### Dawn 4.2 Testnet
N
noprom 已提交
177

N
noprom 已提交
178
We can easily set up a Dawn 4.2 local testnet using docker images. Just run the following commands:
N
noprom 已提交
179

N
noprom 已提交
180 181
Note: if you want to use the mongo db plugin, you have to enable it in your `data-dir/config.ini` first.

N
noprom 已提交
182 183
```
# pull images
N
noprom 已提交
184
docker pull eosio/eos:20180528
N
noprom 已提交
185
docker pull mongo:latest
N
noprom 已提交
186 187 188
# create volume
docker volume create --name=nodeos-data-volume
docker volume create --name=keosd-data-volume
N
noprom 已提交
189
docker volume create --name=mongo-data-volume
N
noprom 已提交
190
# start containers
N
noprom 已提交
191
docker-compose -f docker-compose-dawn4.2.yaml up -d
N
noprom 已提交
192 193 194
# get chain info
curl http://127.0.0.1:8888/v1/chain/get_info
# get logs
N
noprom 已提交
195
docker-compose logs -f nodeosd
N
noprom 已提交
196
# stop containers
N
noprom 已提交
197
docker-compose -f docker-compose-dawn4.2.yaml down
N
noprom 已提交
198 199
```

E
ene5135 已提交
200
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.
N
noprom 已提交
201 202 203

### About MongoDB Plugin

S
Sterling Ledet 已提交
204
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.