Docker Hints - Coda Daemon

This is some quick docker commands I put together relating to running a coda daemon!

Related Reading

Generate a private key:

It’s important to note here that without the -v argument, your generated key would be stuck inside the container and deleted when the container exits! This example mounts the current directory pwd inside the container at the /keys path.

Note: the CODA_PRIVKEY_PASS variable in the below command controls the password used to encrypt your private key! Make sure to change it!

docker run --entrypoint /bin/bash -it -v $(pwd)/:/keys codaprotocol/coda-daemon:0.0.11-beta1-release-0.0.12-beta-493b4c6 -c "CODA_PRIVKEY_PASS='password' coda client-old generate-keypair -privkey-path /keys/my_key"

Basic Daemon:

This will run a full node without any extra features.

Note: passing -d to docker run will tell docker to execute the daemon in the background. This will preserve the container when your shell exits.

You can find the container with docker ps and view logs with docker logs <container-id>.

docker run -d --entrypoint /bin/bash codaprotocol/coda-daemon:0.0.11-beta1-release-0.0.12-beta-493b4c6 -c "coda daemon \
-log-level Info -config-directory /root/.coda-config \
-client-port 8301 -rest-port 3085 \
-external-port 8302 -discovery-port 8303 \
-metrics-port 10000  \
 -peer /dns4/seed-one.genesis.o1test.net/tcp/10002/ipfs/12D3KooWP7fTKbyiUcYJGajQDpCFo2rDexgTHFJTxCH8jvcL1eAH \
-peer /dns4/seed-two.genesis.o1test.net/tcp/10002/ipfs/12D3KooWL9ywbiXNfMBqnUKHSB1Q1BaHFNUzppu6JLMVn9TTPFSA"

Block Producers:

This will run a block producer with a key you specify.

export MY_KEY_DIRECTORY=/absolute/path/to/keys
docker run  -d -v $(MY_KEY_DIRECTORY)/:/keys --entrypoint /bin/bash codaprotocol/coda-daemon:0.0.11-beta1-release-0.0.12-beta-493b4c6 -c "coda daemon \
-privkey-path /keys/my_key
-log-level Info -config-directory /root/.coda-config \
-client-port 8301 -rest-port 3085 \
-external-port 8302 -discovery-port 8303 \
-metrics-port 10000  \
 -peer /dns4/seed-one.genesis.o1test.net/tcp/10002/ipfs/12D3KooWP7fTKbyiUcYJGajQDpCFo2rDexgTHFJTxCH8jvcL1eAH \
-peer /dns4/seed-two.genesis.o1test.net/tcp/10002/ipfs/12D3KooWL9ywbiXNfMBqnUKHSB1Q1BaHFNUzppu6JLMVn9TTPFSA"

Snark Worker:

This will run a SNARK worker. As there are no external components (like a private key) that need to be provided, no volumes!

docker run  -d --entrypoint /bin/bash codaprotocol/coda-daemon:0.0.11-beta1-release-0.0.12-beta-493b4c6 -c "coda daemon \
-snark-key <PUBLIC_KEY> 
-snark-fee 20
-log-level Info -config-directory /root/.coda-config \
-client-port 8301 -rest-port 3085 \
-external-port 8302 -discovery-port 8303 \
-metrics-port 10000  \
 -peer /dns4/seed-one.genesis.o1test.net/tcp/10002/ipfs/12D3KooWP7fTKbyiUcYJGajQDpCFo2rDexgTHFJTxCH8jvcL1eAH \
-peer /dns4/seed-two.genesis.o1test.net/tcp/10002/ipfs/12D3KooWL9ywbiXNfMBqnUKHSB1Q1BaHFNUzppu6JLMVn9TTPFSA"

Accessing Your Daemon Container

Once you run your daemon in the background, it’s useful to be able to login and check on it!

First, list all your containers:

docker ps

You should see something like this:

CONTAINER ID        IMAGE                                                                COMMAND                  CREATED             STATUS              PORTS               NAMES
0f5f5da9342b        codaprotocol/coda-daemon:0.0.11-beta1-release-0.0.12-beta-493b4c6    "/bin/bash -c 'coda …"   14 hours ago        Up 14 hours                      

Copy the container id of the container you’d like to access and use docker exec to get a shell in the container:

docker exec -it <container-id> bash

For Example:

$ docker exec -it 0f5f5da9342b bash
root@genesis-seed-one:/#