Run Crossbar with Docker Compose
Last updated
Last updated
Crossbar can be run pretty easily with Docker. The instructions below will walk you through running Crossbar in Docker containers using Docker Compose.
For Swagger documentation, see:
Crossbar uses another piece of software called Task Runner Simulator to simulate feeds. You can provide Crossbar with the address of the Task Runner Simulator instance via an environment variable. If you don't provide it, Crossbar will fall back on using the public Task Runner Simulator endpoint at crossbar.switchboard.xyz
, however it's not recommended to rely on this and we don't provide any guarantee of service. The instructions in this guide include running the Task Runner Simulator server alongside Crossbar.
Before running crossbar, ensure you have the following
Docker and Docker Compose installed on your machine.
A custom Solana RPC for Task Runner Simulator actions (optional - strongly recommended)
Pinata or another IPFS node for job storage
Create a Project Directory: Create a directory for your project. This directory will contain all the necessary files for your Docker container deployment.
mkdir my-crossbar-project cd my-crossbar-project
docker-compose.yml
FileCreate a docker-compose.yml
File: In your project directory, create a file named docker-compose.yml
. This file will define the Docker services and environment variables.
.env
FileCreate a .env
File: In the same directory, create a .env
file to store your environment variables. This file is read by docker compose
and will override the default values in the compose file if specified.
Build and Run the Docker Container: Navigate to your project directory and run the following command to start your Docker container:
docker-compose up -d
This command will start the container in detached mode. The -d
flag stands for "detached," meaning the container runs in the background.
Verify the Deployment: Once the container is running, you can verify that the service is up and running by accessing it at http://localhost:8080
. You can also check the status of the container by running:
docker-compose ps
This command will show the status of the running services.
Stop the Docker Container: To stop the container, run:
docker-compose down
This command will stop and remove the containers defined in your docker-compose.yml
file.
Restart the Docker Container: To restart the container, run:
docker-compose up -d
Logs: To view the logs of the running container, use the following command:
docker-compose logs -f
Updating Environment Variables: If you need to update the environment variables, edit the .env
file and restart the container:
docker-compose down docker-compose up -d
Try the deployment out by navigating to (can take a few seconds the first run):
The equivalent result should look something like the output from the public node: