diff --git a/README.md b/README.md index 9b5f7548..0336b48d 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ Refer to [INSTALL.md](INSTALL.md) Make sure `bitcoind` is running before running `teosd` (it will fail at startup if it cannot connect to `bitcoind`). [Here](DEPENDENCIES.md#installing-bitcoind) you can find a sample bitcoin.conf. +Please see [Docker instructions](docker/README.md) for instructions on how to set up `teosd` in Docker. + ### Starting the tower daemon ♖ Once installed, you can start the tower by running: diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..341e7cab --- /dev/null +++ b/docker/README.md @@ -0,0 +1,87 @@ +## Running `teosd` in a docker container +A `teos` image can be built from the Dockerfile located in `docker`. You can create the image by running: + + cd rust-teos + docker build -f docker/Dockerfile -t teos . + +Then you can create a container by running: + + docker run -it -e teos + +Notice that ENV variables are optional, if unset the corresponding default setting is used. The following ENVs are available: + +``` +- API_BIND= +- API_PORT= +- RPC_BIND= +- RPC_PORT= +- BTC_NETWORK= +- BTC_RPC_CONNECT= +- BTC_RPC_PORT= +- BTC_RPC_USER= +- BTC_RPC_PASSWORD= +- DATA_DIR= +- DEBUG= +- DEPS_DEBUG= +- OVERWRITE_KEY= +- FORCE_UPDATE= +``` + +You may also want to run docker with a volume, so you can have data persistence in `teosd` databases and keys. +If so, run: + + docker volume create teos-data + +And add the the mount parameter to `docker run`: + + --mount source=teos-data,target=/root/.teos + +If you are running `teosd` and `bitcoind` in the same machine, continue reading for how to create the container based on your OS. + +### `bitcoind` running on the same machine (UNIX) +The easiest way to run both together in he same machine using UNIX is to set the container to use the host network. + +For example, if both `teosd` and `bitcoind` are running on default settings, run + +``` +docker run --network=host \ + --name teos \ + --mount source=teos-data,target=/root/.teos \ + -e BTC_RPC_CONNECT=host.docker.internal \ + -e BTC_RPC_USER= \ + -e BTC_RPC_PASSWORD= \ + -it teos +``` + +Notice that you may still need to set your RPC authentication details, since, hopefully, your credentials won't match the `teosd` defaults. + +### `bitcoind` running on the same machine (OSX or Windows) + +Docker for OSX and Windows does not allow to use the host network (nor to use the `docker0` bridge interface). To workaround this +you can use the special `host.docker.internal` domain. + +``` +docker run -p 9814:9814 \ + --name teos \ + --mount source=teos-data,target=/root/.teos \ + -e BTC_RPC_CONNECT=host.docker.internal \ + -e BTC_RPC_USER= \ + -e BTC_RPC_PASSWORD= \ + -e API_BIND=0.0.0.0 \ + -it teos +``` + +Notice that we also needed to add `API_BIND=0.0.0.0` to bind the API to all interfaces of the container. +Otherwise it will bind to `localhost` and we won't be able to send requests to the tower from the host. + +### Using `teos-cli` + +With this set up, there are two ways you can use `teos-cli` + +You can open an `sh` shell using `docker exec`: + +`docker exec -it sh` + +Then begin issuing whatever `teos-cli` commands you want. + +Secondly, you can try using teos-cli remotely following the instructions in [the main README](https://github.com/talaia-labs/rust-teos/blob/master/README.md#running-teos-cli-remotely).