my-container-api

$npx mdskill add myapihq/myapi/my-container-api

Run containers on demand for services, workers, or scheduled jobs.

  • Deploy pre-built Docker images as long-running services or background workers.
  • Depends on container runtime, cloud infrastructure, and custom domain DNS.
  • Chooses container type based on user input: service, worker, or cron job.
  • Returns a live URL and scoped API key for the running container.

SKILL.md

.github/skills/my-container-apiView on GitHub ↗
---
name: my-container-api
version: 1.0.0
description: >
  Run containers on demand — long-running services, background workers, and scheduled jobs. The heavier-duty sibling of edge functions, for native deps and long execution.
triggers: [container, cloud run, dynamic app, custom domain app, service, worker, scheduled job, deploy container, docker image]
checksum: sha256-pending
---

# MyContainerAPI

A container runs a pre-built image on managed cloud infrastructure. Three types: a **service** (HTTP server, scales to zero), a **worker** (always-on background process), or a **job** (runs to completion — the only type that takes a cron schedule). Containers are the heavier-duty sibling of edge functions (`myapi fn`) — use them for native dependencies, long execution, or a full dynamic app.

## Capabilities
<!-- llm:start -->
The lifecycle is **create → deploy → (optionally) bind a custom domain**.

- `create` registers the container and issues a **scoped API key**, returned once. The running container receives it as the `MYAPI_KEY` env var, so your code calls other MyAPI slots with no token handling. Deploy rotates this key.
- `deploy` ships a pre-built image reference to the runtime and makes the container live at a generated URL.
- `domain` puts the container on a **custom domain** — how you serve a dynamic app at `app.yourbrand.com`.

### Custom domains (dynamic apps)

`myapi container domain <id> <domain>` binds a custom domain to a **deployed** container, served over HTTPS automatically. This is the path for a dynamic backend on a real domain — distinct from `my-funnel-api`, which serves static sites.

Get it right:

- **Deploy first.** Binding a domain to a container that has never deployed fails (422) — there is nothing running to route to.
- **Register the parent domain first.** The domain's MyAPI-managed parent must already be registered via `my-domain-api`. Binding `app.synthesisdaily.com` requires `synthesisdaily.com` registered in MyAPI; otherwise 422.
- **One domain per container.** Re-binding, or binding a hostname already taken, fails (409).
- `--remove` unbinds. `myapi container get <id>` shows the bound `custom_domain`.
<!-- llm:end -->

## Commands
<!-- generated:start -->
| Command | What it does |
|---|---|
| `myapi container create --name <name> [--type service\|worker\|job] [--cron <expr>] [--cpu <n>] [--memory <size>] [--port <n>] [--env K=V,...]` | Register a container, get its scoped API key (once) |
| `myapi container deploy <id> <image-ref>` | Ship a pre-built image and go live (rotates the scoped key) |
| `myapi container list` | List containers in your org |
| `myapi container get <id>` | Inspect a container (status, URL, custom domain) |
| `myapi container logs <id> [--tail <n>]` | Recent runtime logs, newest first |
| `myapi container domain <id> <domain>` | Bind a custom domain (`--remove` to unbind) |
| `myapi container delete <id>` | Soft-delete and revoke its scoped API key |
<!-- generated:end -->

## Examples
<!-- llm:start -->
```bash
# 1. Register a service container
myapi container create --name api --type service --port 8080
# → prints a scoped API key ONCE — save it if your code needs it

# 2. Deploy a pre-built image
myapi container deploy <id> registry.example.com/my-app:v1

# 3. Serve it on a custom domain. The parent domain must already be
#    registered: myapi domain register synthesisdaily.com
myapi container domain <id> app.synthesisdaily.com
# → app.synthesisdaily.com now serves the container over HTTPS

myapi container get <id>          # shows status, URL, custom_domain
myapi container logs <id> --tail 100

# Unbind the custom domain
myapi container domain <id> --remove
```
<!-- llm:end -->

## Notes

- The scoped API key is shown **once** at create, and again (rotated) on every deploy. Save it if your code needs it.
- A `worker` is forced to ≥1 instance; a `service` scales to zero; only a `job` accepts `--cron`.
- Custom domains need a deployed container **and** a MyAPI-registered parent domain — see `my-domain-api`.
- Containers are for dynamic apps and native deps. For static sites use `my-funnel-api`; for edge functions use `my-function-api`.

Run `myapi container --help` for the full flag reference.

More from myapihq/myapi