Set Up cored Using Docker

Steps to Install cored

1. Install Docker

Ensure Docker is installed on your machine. You can download Docker from the Docker official website

2. Create the Dockerfile

Create a file named Dockerfile and add the following content:

# Use Alpine Linux for the final image
FROM alpine:latest as base 

# Install necessary packages
RUN apk add --no-cache ca-certificates curl bash

# Set environment variables
ENV COREUM_CHAIN_ID="coreum-testnet-1"
ENV COREUM_DENOM="utestcore"
ENV CORED_NODE="https://full-node.testnet-1.coreum.dev:26657"
ENV COREUM_VERSION="v4.1.0" # use the latest version

ENV COREUM_CHAIN_ID_ARGS="--chain-id=$COREUM_CHAIN_ID"
ENV COREUM_NODE_ARGS="--node=$COREUM_NODE"

ENV COREUM_HOME="/root/.core/$COREUM_CHAIN_ID"
ENV COREUM_BINARY_NAME=cored-linux-amd64

# Create directories
RUN mkdir -p $COREUM_HOME/bin

# Download the cored binary
RUN curl -Lo $COREUM_HOME/bin/cored https://github.com/CoreumFoundation/coreum/releases/download/$COREUM_VERSION/$COREUM_BINARY_NAME

# Make the binary executable
RUN chmod +x $COREUM_HOME/bin/cored

# Add the binary to PATH
ENV PATH=$PATH:$COREUM_HOME/bin

# Expose the necessary ports (adjust these if needed based on the application requirements)
EXPOSE 26656 26657 9090 9091 1317 6060 26660

# Set a command or script that keeps the container running since the ENTRYPOINT is not starting the node
CMD ["tail", "-f", "/dev/null"]

3. Build the Docker Image

Build the Docker image using the Dockerfile. Open a terminal, navigate to the directory containing the Dockerfile, and run:

 docker build -t coreum-cored .

4. Run the docker Container

Run the Docker container using the built image:

docker run -d --name coreum-cored-container -p 26656:26656 -p 26657:26657 -p 9090:9090 -p 9091:9091 -p 1317:1317 -p 6060:6060 -p 26660:26660 coreum-cored

This command runs the container in detached mode (-d), names it coreum-cored-container, and maps the necessary ports.

5. Verify the Container is Running

Check if the container is running:

docker ps

You should see coreum-cored-container listed.

6. Verify the Container is Running

To access the running container and verify that the cored binary is correctly set up, use:

docker exec -it coreum-cored-container /bin/bash

7. Test Cored

cored version