Running Docker images
Running Docker images is similar to running binaries. We can run a Docker image with yeet
like this:
yeet run <service> <image>
What's happening here is that we are pushing your image to a special Docker registry running inside of Catch. This is a private registry that is scoped to your server and is not accessible from the public internet.
After receiving our image, Catch automatically runs the image for us!
Examples
Deploying a static website
In this example, we'll deploy a static website built with Hugo. Our Dockerfile
will use a multi-stage build to compile
our Hugo site and then serve it with Nginx.
# Dockerfile
FROM klakegg/hugo:0.92.0-alpine AS builder
WORKDIR /src
COPY . .
RUN hugo --minify
FROM nginx:alpine
COPY --from=builder /src/public /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
The first step to deploying our Docker image is to build it. We can do this with docker build
. We'll tag our image
with static-site
so that we can easily identify it later.
docker build -t static-site .
Once we have our image, we can run it with yeet run
.
yeet run static-site static-site
Catch will automatically detect that we are trying to run a Docker image and will handle the push and execution for us.
Under the hood, Catch generates a docker-compose.yml
file, which we can edit remotely to map ports to our service.
To edit the docker-compose.yml
file, we can use the yeet edit
command.
yeet edit static-site
Let's map port 8080
on our server to port 80
in our container.
services:
nginx:
image: catchit.dev/nginx/nginx
restart: unless-stopped
volumes:
- /root/data/services/nginx/data:/data
ports: # Add these lines
- "8080:80"
Save and close the file and Catch will automatically restart our service. We can access our website at http://<server-ip>:8080.
Catch includes a built-in TCP proxy, enabling you to access your services over the Tailnet. This means you can visit http://catch:8080 to also access your website.