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

H
Huang-Ming Huang 已提交
3
Simple and fast setup of EOS 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
peterwillcn's avatar
peterwillcn 已提交
7

S
Sandwich 已提交
8
## Build eos image
peterwillcn's avatar
peterwillcn 已提交
9

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

H
Huang-Ming Huang 已提交
16
## Start eosd docker container only
peterwillcn's avatar
peterwillcn 已提交
17

S
Sandwich 已提交
18
```bash
H
Huang-Ming Huang 已提交
19
docker run --name eosd -p 8888:8888 -p 9876:9876 -t eosio/eos start_eosd.sh arg1 arg2
peterwillcn's avatar
peterwillcn 已提交
20
```
S
Sandwich 已提交
21

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

H
Huang-Ming Huang 已提交
29
Alternately, you can directly mount host directory into the container
H
Huang-Ming Huang 已提交
30
```bash
H
Huang-Ming Huang 已提交
31
docker run --name eosd -v /path-to-data-dir:/opt/eos/bin/data-dir -p 8888:8888 -p 9876:9876 -t eosio/eos start_eosd.sh arg1 arg2
H
Huang-Ming Huang 已提交
32 33
```

S
Sandwich 已提交
34 35 36
## Get chain info

```bash
peterwillcn's avatar
peterwillcn 已提交
37
curl http://127.0.0.1:8888/v1/chain/get_info
peterwillcn's avatar
peterwillcn 已提交
38 39
```

H
Huang-Ming Huang 已提交
40 41 42 43 44 45 46 47 48 49
## Start both eosd and walletd containers

```bash
docker-compose up
```

After `docker-compose up`, two services named eosd and walletd will be started. eosd 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 eosc when runing eosc is running inside the walletd container as described in "Execute eosc commands" section.


### Execute eosc commands
peterwillcn's avatar
peterwillcn 已提交
50

H
Huang-Ming Huang 已提交
51
You can run the `eosc` commands via a bash alias.
S
Sandwich 已提交
52 53

```bash
H
Huang-Ming Huang 已提交
54 55 56
alias eosc='docker-compose exec walletd /opt/eos/bin/eosc -H eosd'
eosc get info
eosc get account inita
peterwillcn's avatar
peterwillcn 已提交
57 58
```

H
Huang-Ming Huang 已提交
59 60
Upload sample exchange contract

S
Sandwich 已提交
61
```bash
H
Huang-Ming Huang 已提交
62
eosc set contract exchange contracts/exchange/exchange.wast contracts/exchange/exchange.abi
peterwillcn's avatar
peterwillcn 已提交
63 64
```

H
Huang-Ming Huang 已提交
65
If you don't need walletd afterwards, you can stop the walletd service using
S
Sandwich 已提交
66 67

```bash
H
Huang-Ming Huang 已提交
68 69
docker-compose stop walletd
```
H
Huang-Ming Huang 已提交
70
### Change default configuration
H
Huang-Ming Huang 已提交
71 72 73 74 75 76 77 78 79 80 81

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:
  eosd:
    volumes:
      - eosd-data-volume:/opt/eos/bin/data-dir
      - ./config2.ini:/opt/eos/bin/data-dir/config.ini
S
Sandwich 已提交
82 83
```

H
Huang-Ming Huang 已提交
84
Then restart your docker containers as follows:
S
Sandwich 已提交
85 86

```bash
H
Huang-Ming Huang 已提交
87 88 89
docker-compose down
docker-compose up
```
H
Huang-Ming Huang 已提交
90 91 92 93 94 95 96

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

```bash
docker volume rm docker_eosd-data-volume
```