Skip to content
You are reading the Teku development version documentation and some features may not be available in the stable release. You can switch to the stable version using the version box at the bottom of the screen.

Updated on November 12, 2020

Running Teku from a Docker image

Use the Teku Docker image to run a node without installing Teku.

Prerequisites:

Run Teku Docker image

Display the Teku command line help using the Docker image

docker run consensys/teku:latest --help

You can specify Teku environment variables with the docker image instead of the command line options.

Example using Environment variables and CLI options

docker run -d -p 9000:9000 -p 5051:5051 -e TEKU_REST_API_ENABLED=true -e TEKU_P2P_PORT=9000 --mount type=bind,source=/Users/user1/teku/,target=/var/lib/teku consensys/teku:latest --network=medalla --eth1-endpoint=http://102.10.10.1:8545 --validator-keys=/var/lib/teku/validator/keys:/var/lib/teku/validator/passwords --data-path=/var/lib/teku --log-destination=CONSOLE

Tips

Allow multiple users to run the Docker image

If using a local volume to mount data, ensure the permissions on the directory allow other users and groups to read/write.

Use the Docker --user option to run the container for the specified user. Use the UID because the username may not exist inside the docker container.

Example

docker run -p 9000:9000 --user 1001:1001 --mount type=bind,source=/Users/user1/teku/,target=/var/lib/teku consensys/teku:latest --network=medalla --eth1-endpoint=http://102.10.10.1:8545 --validator-keys=var/lib/teku/validator/keys:var/lib/teku/validator/passwords

Exposing ports

Expose ports for P2P peer discovery, metrics, and REST APIs. Expose the default ports or the ports specified using:

To run Teku exposing local ports for access:

docker run -p <localportP2P>:30303 -p <localportREST>:5051 consensys/teku:latest --network=<NETWORK> --eth1-endpoint=<URL> --validator-keys=<KEY_DIR>:<PASS_DIR> --rest-api-enabled=true

Example

docker run -p 30303:30303 -p 5051:5051 --mount type=bind,source=/Users/user1/teku/,target=/var/lib/teku consensys/teku:latest --network=medalla --eth1-endpoint=http://102.10.10.1:8545 --validator-keys=var/lib/teku/validator/keys:var/lib/teku/validator/passwords --rest-api-enabled=true

Run Teku using Docker Compose

Prerequisites:

The following docker-compose.yml file starts a Hyperledger Besu and Teku node.

Note

The example assumes the validators specified in --validator-keys has already been registered in the Ethereum 1.0 deposit contract.

Run docker-compose up in the directory containing the docker-compose.yml file to start the container.

---
version: '3.4'
services:

  besu_node:
    image: hyperledger/besu:latest
    command: ["--network=goerli",
              "--data-path=/opt/besu/data/data",
              "--host-allowlist=*",
              "--sync-mode=FAST",
              "--rpc-http-enabled",
              "--rpc-http-cors-origins=*",
              "--rpc-http-api=ETH,NET,CLIQUE,DEBUG,MINER,NET,PERM,ADMIN,EEA,TXPOOL,PRIV,WEB3"]
    volumes:
      - ./besu:/opt/besu/data
    ports:
      # Map the p2p port(30303) and RPC HTTP port(8545)
      - "8545:8545"
      - "30303:30303"

  teku_node:
    image: consensys/teku:latest
    command: ["--network=medalla",
              "--eth1-endpoint=http://besu_node:8545",
              "--validator-keys=/opt/teku/data/validator/keys:/opt/teku/data/validator/passwords",
              "--p2p-port=9000",
              "--rest-api-enabled=true",
              "--rest-api-docs-enabled=true"]
    depends_on:
      - besu_node
    volumes:
      - ./teku:/opt/teku/data
    ports:
      # Map the p2p port(9000) and REST API port(5051)
      - "9000:9000"
      - "5051:5051"
Questions or feedback? You can discuss issues and obtain free support on Teku Discord channel.
For paid professional support by Consensys, contact us at quorum@consensys.net