Background
Deploying and coordinating Docker containers in a production environment can be quite the challenge. This is where our open-source project Bacalhau comes in handy and the reason why we at Expanso developed this project in the first place. The Bacalhau Project enables you to deploy containers on a network of endpoints, the so-called nodes, while being secure, fast, and cost-efficient. This architecture is referred to as Compute over Data (CoD) and enables users to run compute jobs where the data is generated and stored, the so-called edge. You can read more in this post about the Bacalhau project.
Step 1: Installation of CLI
To install Bacalhau on your local machine you execute the following command on your terminal. This installs or updates the Bacalhau CLI just on your local device.
curl -sL https://get.bacalhau.org/install.sh | bash
This command installs the latest Bacalhau version, which we can check with the version command.
bacalhau version
If you're wondering which server is being used, the Bacalhau Project has a public Demo network that's shared with the community (anyone can access this network). We will use this network for the ease of use, as this server allows you to launch your jobs from your computer without maintaining a compute cluster on your own. You can also deploy your own private network following this tutorial.
Step 2: Submit Your First Job
After having installed the CLI, we can now directly interact with the network. This makes our lives easier, because we can now use the bacalhau command pallet to submit a job in Bacalhau. Let's take a quick look at its syntax.
bacalhau docker run [FLAGS] IMAGE[:TAG] [COMMAND]
This command is pretty similar to the one used for docker and allows for three different inputs: potential flags, the required image we want to use and the command we want to execute. Here you can learn more about the usable commands. This can look as the following.
bacalhau docker run ubuntu echo Hello World
This now runs the echo “Hello World” command against the pre-installed ubuntu image on the public network. The results should be a command line output, which confirms the successful job execution.
Congratulations, you just ran your first job on Bacalhau!
Step 3: Checking The Status
After successfully submitting our first job, we also want to check the status. In order to uniquely identify your job, the job_id
above is shown in its full form. For convenience, you can use the shortened version (in this case: 3b39baee
) and execute the list command. Your job ID will differ from this example, as the IDs are unique for a network. You can find your job ID in the command line output.
bacalhau list --id-filter 3b39baee
This will list the job IDs starting with 3b39baee
and their job information. We can also describe the executed commands, to get better insights.
bacalhau describe 3b39baee
Step 4: View The Output
After checking the status of our job, we can now download the job results. This may seem over the head for a “Hello world” command, but comes in handy when executing large scale jobs. You can download your job results directly by using bacalhau get
. In the command below we download our job output to be stored in our local directory. For this the default user directory is used, which should be stated in your command line output.
bacalhau get 3b39baee
To get the results from the job executed on the Bacalhau network, we can just read the output file in our job folder.
cat job-3b39baee/stdout
This prints out the string output produced by our job to your local command line. The job output folder contains multiple files, containing all the important information from your job execution. You can have a look inside and explore the other files.
What’s Next?
After completing our first job on Bacalhau, one can now onboard existing Docker or WASM workloads to work with Bacalhau or can also setup your own private Bacalhau network.
Stay tuned as we continue to enhance and expand Bacalhau's capabilities. We are relentlessly committed to delivering groundbreaking updates and improvements. Don't miss out on being part of this exciting journey.
The Bacalhau project is available today as Open Source Software. The public GitHub repo can be found here. If you like the project, please give us a star ⭐ 🙂
We're looking for help in several areas. If you're interested in helping out, there are several ways to contribute and you can always reach out to us via Slack or Email.