Running Docker Compose
Similar to running Docker images, Catch can run Docker Compose files. This is useful for deploying multiple services
together. Just like with Docker images, you can run a Docker Compose file with yeet run
.
yeet run my_service docker-compose.yml
Catch will automatically detect that the file is a Docker Compose file and run it for you.
Examples
Deploying Grafana and Prometheus
Let's deploy this example of Grafana alongside Prometheus. The docker-compose.yml
file defines these two services and uses their well-known public image names.
# docker-compose.yml
services:
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
Once we're happy with our docker-compose.yml
file, we can run it with yeet run
, just like we would run any other
service.
yeet run grafana-prometheus docker-compose.yml
Catch will automatically detect that the file is a Docker Compose file and bring up the services for us.
Run yeet status <service>
to see the status of the services.
$ yeet status grafana-prometheus
SERVICE TYPE CONTAINER STATUS
grafana-prometheus docker grafana running
grafana-prometheus docker prometheus running
Run yeet logs <service>
to see the logs for a service.
Deploying a Node.js application
Another common use case is deploying your own Dockerfile along with other services. For example, let's say we have a Node.js application we want to deploy alongside Postgres.
Let's start by creating a Dockerfile that copies our app and bundles it with Node.js.
# Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY . .
RUN npm install
CMD ["node", "index.js"]
We can then create a docker-compose.yml
file that runs our Postgres service and our Node.js service.
# docker-compose.yml
services:
app:
build: .
image: catchit.dev/my-node-app/app # <-- Name your image
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres
db:
image: postgres:latest
In the docker-compose.yml
above we define two services. The first, app
, builds our Node.js application using the
Dockerfile we created earlier. The second, db
, uses the official Postgres image from the Docker Hub.
One important thing to note is that we've tagged our image as catchit.dev/my-node-app/app
. This allows yeet
to find
and automatically push the image to the Catch registry.
In order for this to work, the name of the image should use the format catchit.dev/<service-name>/<image-name>
.
Once we're happy with our docker-compose.yml
file, we will have Docker build and tag our image for us.
docker compose build
Now we are ready to run our service with yeet run
.
yeet run my-node-app docker-compose.yml
The catchit.dev/my-node-app/app
image will be automatically pushed to the Catch registry.
We can run yeet status <service>
to see the status of the services.
$ yeet status my-node-app
SERVICE TYPE CONTAINER STATUS
my-node-app docker app running
my-node-app docker db running
View the logs for a service with yeet logs <service>
.
yeet logs my-node-app