Part 3 - Hyper Compose

In part 2 we saw how to get containers to interact with each other in Hyper using the --link flag of the hyper run command. That works fine, but you have many containers working together it can be tedious to create and manage them using only the CLI. Docker solved this problem with Docker Compose, and Hyper Compose works in exactly the same way.

Hyper Compose for a single container

Let’s start by using Hyper Compose to start the single container example that we saw in Part 1. As with Docker Compose, we need a compose file:

Note on the term ‘service’
You’ll notice in the Docker Compose format that each container is referred to as a ‘service:’. This is not the same as the Hyper Service functionality which is outside of the scope of this guide. You can read more about Hyper Service in the docs here: https://docs.hyper.sh/Feature/container/service.html

Above you can see that Hyper Compose and Docker Compose have pretty much the same format. In fact in most cases you can just run an existing Docker Compose file using Hyper Compose. The size and FIP fields are not present in Docker Compose, but as we’ve seen earlier in this guide, these are specific to Hyper.

Let’s save the compose file locally as myfirstcompose.yml and try it out. Remember to insert your own FIP!

And that’s it. The Jenkins example that we looked at in Part 1 will now be up and running and accessible on <YOUR FIP>:8080

Note on changing compose files
If you want to make a change to your compose file, remember to first run hyper compose down, and then hyper compose up again to make sure that all changes are processed correctly.

Lastly, we’ll stop the container by using the hyper compose down command.

Note on external volumes with Hyper Compose
As you start to use Hyper Compose you’ll be able to get work much more quickly, but you’ll also be able to create lots of volumes. Make sure to use hyper volume ls afterwards to check which Hyper Volumes and lying around and hyper volume rm to remove those that you no longer need.

Hyper Compose for multiple containers

Now that you’re familiar with Hyper Compose, let’s use the Wordpress example from Part 2 to look at a multi-container Hyper Compose example. Here’s the compose file:

As you can see, we have added two ‘services’ in this example, MySQL and Wordpress and the compose file parameters are exactly the same as those we used via the CLI in Part 2.

The depends_on field makes sure that the mysqldb service is started before the Wordpress container. You can now save the above compose file locally and start the whole Wordpress application using the following command:

And that’s it! You will now have your Wordpress application running and accessible publicly via your FIP.

Note on output from Hyper Compose
Most of the time you probably will not want to stream all output from Hyper Compose to standard err/out. To stop this you can add the -d flag to the hyper compose up command. You can then use hyper logs on the individual containers to see their output.