About
A Container runs your app from an image and adds instances as traffic grows, down to none when nobody calls it (--min-instances 0). Each deploy creates a revision; the newest receives all traffic, and you can send traffic back to an earlier one at any time.
- From source (
--source, the default): th packs the folder and we build it, so you don’t need Docker. ADockerfileis used when there is one; otherwise Node.js, Python and Go projects get one written for them, shown in the build log. Files listed in.thignore(else.dockerignore, else.gitignore) are not uploaded, and the packed source may be up to 100 MB. - From an image (
--image): any image the platform can pull, or one you pushed with Docker afterth auth configure-docker. - Settings: the first deploy creates the Container (it needs a region). Later deploys keep its settings and change only the parameters you pass. Environment parameters replace the whole set of variables.
- Registry: built and pushed images are kept in the Project’s registry, 20 GB per Project. The images of the newest 10 revisions of each Container and any tagged image are kept. Build into another registry with
--repository, and manage registries with th registry.
Your app must listen on 0.0.0.0 on the port in $PORT (default 8080). See the help centre’s How Containers work for scaling and access.
How-to guides
Deploy from source
- In your project folder, run
th container deploy api --source .(the first time add--region, or set one withth config set region). - th packs and uploads the folder, then streams the build log to your terminal.
- When the build succeeds, the new revision is deployed and the service URL is printed.
th container deploy api --source . --region bkkPress Ctrl+C during the build and it keeps running on our side. Follow it again with th builds log <id> --follow.
Deploy an image and change settings
th container deploy api --image ghcr.io/acme/api:1.4 --port 3000
th container deploy api --cpu 1 --memory 512Mi --min-instances 0 --max-instances 5 \
--set-env-vars NODE_ENV=production --secret-env API_KEY=xxxxParameters you leave out keep the service’s current values. --env, --set-env-vars and --secret-env together replace every variable, so pass all of them each time you change one.
Roll back to an earlier revision
- List the revisions with
th container revisions list --service api;*marks the one serving. - Send all traffic to the one you want:
th container services update-traffic api --to-revision 3. - To go forward again, use
--to-revision LATEST.
th container revisions list --service api
th container services update-traffic api --to-revision 3Free registry space
- See how much each repository uses with
th container images list. - List one repository’s images with
th container images list api.KEPT=yesmeans a Container runs the image or a revision keeps it for rolling back. - Delete a tag (
api:old-tag), an image by digest (api@sha256:…), or a whole repository nothing runs.
th container images list
th container images list api
th container images delete api:old-tag
th container images delete-repository old-workerCommands
| Command | Description |
|---|---|
th container deploy | Deploys a Container. |
th container services list | Lists the Containers of the active Project. |
th container services describe | Shows a Container's settings and serving revision. |
th container services logs | Prints the latest log lines of a Container. |
th container services update-traffic | Sends all traffic to an earlier (or later) revision. |
th container services delete | Deletes a Container and all its revisions. |
th container revisions list | Lists a Container's revisions, newest first. |
th container images list | Without REPOSITORY lists the Project's registry repositories and how much of the registry quota they use. |
th container images delete | IMAGE is REPOSITORY:TAG (removes only the tag), REPOSITORY@sha256:DIGEST or REPOSITORY@<first 7+ hex of the digest> (removes the image and all its tags), or the full <host>/<namespace>/REPOSITORY[:TAG|@DIGEST]. |
th container images delete-repository | Deletes a repository with all its images and tags. |
th builds list | Lists the Project's latest 100 builds, Containers and Functions alike, newest first. |
th builds log | Prints a build's log; --follow keeps printing until the build ends. |
th builds cancel | Stops a queued or running build. |
th container deploy
Deploys a Container.
Syntax
th container deploy NAME [--source DIR | --image IMAGE] [flags]With --source (the default, "."), the directory is uploaded and built on ThailandHosting — no Docker needed locally — from its Dockerfile, or a generated one for Node.js, Go or Python. Files listed in .thignore (else .dockerignore, else .gitignore) are not uploaded.
A new service is created when NAME does not exist yet (it needs a region); otherwise a new revision of it is deployed and receives all traffic. Flags you leave out keep the service's current settings.
A source build stores its image in the Project's default registry, as <host>/<project>/NAME; --repository REGISTRY/IMAGE stores it in another registry of the Project instead (see th registry list).
Examples
Build the current folder and deploy it as a new Container in bkk
th container deploy api --source . --region bkkBuild into the registry prod as prod/api:v1.4.0
th container deploy api --source . --repository prod/api --tag v1.4.0Deploy an image that listens on port 3000
th container deploy api --image ghcr.io/acme/api:1.4 --port 3000Change the size and set a variable
th container deploy api --cpu 0.5 --memory 512Mi --env NODE_ENV=productionScale to zero when idle, up to 5 instances
th container deploy api --min-instances 0 --max-instances 5 --concurrency 80Require an invoker token from callers
th container deploy api --no-allow-unauthenticatedIn CI: no prompts
th container deploy api --source . --quietPositional arguments
| Name | Description |
|---|---|
NAMERequired | The Container (service) name. It becomes part of the service URL. |
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
--source | string | . | Directory to upload and build |
--image | string | Deploy this image instead of building | |
--port | number | 8080 | Port the container listens on |
--cpu | string | vCPU, e.g. 0.25, 0.5, 1, 2 | |
--memory | string | Memory, e.g. 256Mi, 512Mi, 1Gi | |
--compute-class | string | Compute class, e.g. general, economy, highcpu, highmem | |
--env | list | Environment variable KEY=VALUE (repeatable) | |
--set-env-vars | list | Environment variables KEY=VALUE,KEY2=VALUE2 | |
--secret-env | list | Secret environment variable KEY=VALUE (repeatable) | |
--min-instances | number | Minimum instances (0 scales to zero) | |
--max-instances | number | Maximum instances | |
--concurrency | number | Requests per instance at once | |
--timeout | string | Request timeout, e.g. 300s or 5m | |
--allow-unauthenticated | flag | Allow public calls (--no-allow-unauthenticated needs an invoker token) | |
--cpu-always-allocated | flag | Keep CPU allocated between requests | |
--health-check-path | string | HTTP path for health checks | |
--command | list | Entrypoint, comma-separated (repeatable) | |
--args | list | Arguments, comma-separated (repeatable) | |
--clear-command | flag | Use the image's own entrypoint | |
--clear-args | flag | Use the image's own arguments | |
--dockerfile | string | Dockerfile | Dockerfile path inside the source |
--tag | string | Image tag for a source build | |
--repository | string | NAME | Where a source build stores its image: IMAGE or REGISTRY/IMAGE |
--message | string | Note stored with the revision | |
--async | flag | Return once the deploy is accepted (only with --image) |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th container services list
Lists the Containers of the active Project.
Syntax
th container services listExamples
List the Project’s Containers
th container services listGlobal parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th container services describe
Shows a Container's settings and serving revision.
Syntax
th container services describe NAMEExamples
Show settings and the serving revision
th container services describe apiPositional arguments
| Name | Description |
|---|---|
NAMERequired | The Container (service) name. It becomes part of the service URL. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th container services logs
Prints the latest log lines of a Container.
Syntax
th container services logs NAME [--lines N]Examples
The latest 200 log lines
th container services logs api --lines 200Positional arguments
| Name | Description |
|---|---|
NAMERequired | The Container (service) name. It becomes part of the service URL. |
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
--lines | number | 100 | Number of lines (default 100) |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th container services update-traffic
Sends all traffic to an earlier (or later) revision.
Syntax
th container services update-traffic NAME --to-revision REVREV is a revision name, number, ID or LATEST.
Examples
Roll back to revision 3
th container services update-traffic api --to-revision 3Back to the newest revision
th container services update-traffic api --to-revision LATESTPositional arguments
| Name | Description |
|---|---|
NAMERequired | The Container (service) name. It becomes part of the service URL. |
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
--to-revisionRequired | string | Revision name, number, ID or LATEST |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th container services delete
Deletes a Container and all its revisions.
Syntax
th container services delete NAME [--quiet]--quiet skips the prompt.
Examples
Delete after a prompt
th container services delete apiDelete without a prompt
th container services delete api --quietPositional arguments
| Name | Description |
|---|---|
NAMERequired | The Container (service) name. It becomes part of the service URL. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th container revisions list
Lists a Container's revisions, newest first.
Syntax
th container revisions list --service NAME* marks the serving one.
Examples
List revisions; * marks the serving one
th container revisions list --service apiParameters
| Name | Type | Default | Description |
|---|---|---|---|
--serviceRequired | string | Service name |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th container images list
Without REPOSITORY lists the Project's registry repositories and how much of the registry quota they use.
Syntax
th container images list [REPOSITORY]With REPOSITORY lists its images, newest first. KEPT=yes means a Container runs the image or a revision keeps it for rolling back.
Examples
Repositories and registry use
th container images listImages of the api repository
th container images list apiPositional arguments
| Name | Description |
|---|---|
REPOSITORYOptional | A repository in the Project’s registry, usually the Container’s name. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th container images delete
IMAGE is REPOSITORY:TAG (removes only the tag), REPOSITORY@sha256:DIGEST or REPOSITORY@<first 7+ hex of the digest> (removes the image and all its tags), or the full <host>/<namespace>/REPOSITORY[:TAG|@DIGEST].
Syntax
th container images delete IMAGE [--quiet]An image a Container runs cannot be deleted. --quiet skips the prompt.
Examples
Remove a tag
th container images delete api:old-tagRemove an image and all its tags by digest
th container images delete api@3f2c9a1Positional arguments
| Name | Description |
|---|---|
IMAGERequired | REPOSITORY:TAG, REPOSITORY@sha256:DIGEST, REPOSITORY@ plus the first 7 or more hex digits of the digest, or the full <host>/<namespace>/REPOSITORY…. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th container images delete-repository
Deletes a repository with all its images and tags.
Syntax
th container images delete-repository REPOSITORY [--quiet]It cannot be deleted while a Container runs one of its images. --quiet skips the prompt.
Examples
Delete a repository nothing runs
th container images delete-repository old-workerPositional arguments
| Name | Description |
|---|---|
REPOSITORYRequired | A repository in the Project’s registry, usually the Container’s name. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th builds list
Lists the Project's latest 100 builds, Containers and Functions alike, newest first.
Syntax
th builds list [--status STATUS] [--kind container|function] [--repository REPOSITORY]REPOSITORY is where the image went (IMAGE in the default registry, REGISTRY/IMAGE in another); DEPLOYED TO names the services whose revisions use it. "image removed" means cleanup or a delete took the image out of the registry.
Examples
Builds queued or running now
th builds list --status activeFunction builds that failed
th builds list --kind function --status failedThe latest 100 builds, Containers and Functions
th builds listOnly builds into api
th builds list --repository apiParameters
| Name | Type | Default | Description |
|---|---|---|---|
--status | string | Only builds that are active (queued or running), queued, running, succeeded, failed or cancelled | |
--kind | string | Only container or function builds | |
--repository | string | Only builds into this repository |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th builds log
Prints a build's log; --follow keeps printing until the build ends.
Syntax
th builds log ID [--follow]Examples
Follow a build until it ends
th builds log <build-id> --followPositional arguments
| Name | Description |
|---|---|
IDRequired | The build ID, as printed by th container deploy or th builds list. |
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
--follow | flag | Keep printing until the build ends |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th builds cancel
Stops a queued or running build.
Syntax
th builds cancel IDExamples
Stop a queued or running build
th builds cancel <build-id>Positional arguments
| Name | Description |
|---|---|
IDRequired | The build ID, as printed by th container deploy or th builds list. |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.