th container

Deploy Containers from a folder or an image, roll back to earlier revisions, read logs, and keep your Project’s registry tidy.

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. A Dockerfile is 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 after th 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

  1. In your project folder, run th container deploy api --source . (the first time add --region, or set one with th config set region).
  2. th packs and uploads the folder, then streams the build log to your terminal.
  3. When the build succeeds, the new revision is deployed and the service URL is printed.
Shell
th container deploy api --source . --region bkk

Press 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

Shell
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=xxxx

Parameters 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

  1. List the revisions with th container revisions list --service api; * marks the one serving.
  2. Send all traffic to the one you want: th container services update-traffic api --to-revision 3.
  3. To go forward again, use --to-revision LATEST.
Shell
th container revisions list --service api
th container services update-traffic api --to-revision 3

Free registry space

  1. See how much each repository uses with th container images list.
  2. List one repository’s images with th container images list api. KEPT=yes means a Container runs the image or a revision keeps it for rolling back.
  3. Delete a tag (api:old-tag), an image by digest (api@sha256:…), or a whole repository nothing runs.
Shell
th container images list
th container images list api
th container images delete api:old-tag
th container images delete-repository old-worker

Commands

CommandDescription
th container deployDeploys a Container.
th container services listLists the Containers of the active Project.
th container services describeShows a Container's settings and serving revision.
th container services logsPrints the latest log lines of a Container.
th container services update-trafficSends all traffic to an earlier (or later) revision.
th container services deleteDeletes a Container and all its revisions.
th container revisions listLists a Container's revisions, newest first.
th container images listWithout REPOSITORY lists the Project's registry repositories and how much of the registry quota they use.
th container images deleteIMAGE 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-repositoryDeletes a repository with all its images and tags.
th builds listLists the Project's latest 100 builds, Containers and Functions alike, newest first.
th builds logPrints a build's log; --follow keeps printing until the build ends.
th builds cancelStops a queued or running build.

th container deploy

Deploys a Container.

Syntax

Shell
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

Shell
th container deploy api --source . --region bkk

Build into the registry prod as prod/api:v1.4.0

Shell
th container deploy api --source . --repository prod/api --tag v1.4.0

Deploy an image that listens on port 3000

Shell
th container deploy api --image ghcr.io/acme/api:1.4 --port 3000

Change the size and set a variable

Shell
th container deploy api --cpu 0.5 --memory 512Mi --env NODE_ENV=production

Scale to zero when idle, up to 5 instances

Shell
th container deploy api --min-instances 0 --max-instances 5 --concurrency 80

Require an invoker token from callers

Shell
th container deploy api --no-allow-unauthenticated

In CI: no prompts

Shell
th container deploy api --source . --quiet

Positional arguments

NameDescription
NAMERequiredThe Container (service) name. It becomes part of the service URL.

Parameters

NameTypeDefaultDescription
--sourcestring.Directory to upload and build
--imagestringDeploy this image instead of building
--portnumber8080Port the container listens on
--cpustringvCPU, e.g. 0.25, 0.5, 1, 2
--memorystringMemory, e.g. 256Mi, 512Mi, 1Gi
--compute-classstringCompute class, e.g. general, economy, highcpu, highmem
--envlistEnvironment variable KEY=VALUE (repeatable)
--set-env-varslistEnvironment variables KEY=VALUE,KEY2=VALUE2
--secret-envlistSecret environment variable KEY=VALUE (repeatable)
--min-instancesnumberMinimum instances (0 scales to zero)
--max-instancesnumberMaximum instances
--concurrencynumberRequests per instance at once
--timeoutstringRequest timeout, e.g. 300s or 5m
--allow-unauthenticatedflagAllow public calls (--no-allow-unauthenticated needs an invoker token)
--cpu-always-allocatedflagKeep CPU allocated between requests
--health-check-pathstringHTTP path for health checks
--commandlistEntrypoint, comma-separated (repeatable)
--argslistArguments, comma-separated (repeatable)
--clear-commandflagUse the image's own entrypoint
--clear-argsflagUse the image's own arguments
--dockerfilestringDockerfileDockerfile path inside the source
--tagstringImage tag for a source build
--repositorystringNAMEWhere a source build stores its image: IMAGE or REGISTRY/IMAGE
--messagestringNote stored with the revision
--asyncflagReturn once the deploy is accepted (only with --image)

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th container services list

Lists the Containers of the active Project.

Syntax

Shell
th container services list

Examples

List the Project’s Containers

Shell
th container services list

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th container services describe

Shows a Container's settings and serving revision.

Syntax

Shell
th container services describe NAME

Examples

Show settings and the serving revision

Shell
th container services describe api

Positional arguments

NameDescription
NAMERequiredThe Container (service) name. It becomes part of the service URL.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th container services logs

Prints the latest log lines of a Container.

Syntax

Shell
th container services logs NAME [--lines N]

Examples

The latest 200 log lines

Shell
th container services logs api --lines 200

Positional arguments

NameDescription
NAMERequiredThe Container (service) name. It becomes part of the service URL.

Parameters

NameTypeDefaultDescription
--linesnumber100Number of lines (default 100)

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th container services update-traffic

Sends all traffic to an earlier (or later) revision.

Syntax

Shell
th container services update-traffic NAME --to-revision REV

REV is a revision name, number, ID or LATEST.

Examples

Roll back to revision 3

Shell
th container services update-traffic api --to-revision 3

Back to the newest revision

Shell
th container services update-traffic api --to-revision LATEST

Positional arguments

NameDescription
NAMERequiredThe Container (service) name. It becomes part of the service URL.

Parameters

NameTypeDefaultDescription
--to-revisionRequiredstringRevision name, number, ID or LATEST

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th container services delete

Deletes a Container and all its revisions.

Syntax

Shell
th container services delete NAME [--quiet]

--quiet skips the prompt.

Examples

Delete after a prompt

Shell
th container services delete api

Delete without a prompt

Shell
th container services delete api --quiet

Positional arguments

NameDescription
NAMERequiredThe Container (service) name. It becomes part of the service URL.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th container revisions list

Lists a Container's revisions, newest first.

Syntax

Shell
th container revisions list --service NAME

* marks the serving one.

Examples

List revisions; * marks the serving one

Shell
th container revisions list --service api

Parameters

NameTypeDefaultDescription
--serviceRequiredstringService name

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th container images list

Without REPOSITORY lists the Project's registry repositories and how much of the registry quota they use.

Syntax

Shell
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

Shell
th container images list

Images of the api repository

Shell
th container images list api

Positional arguments

NameDescription
REPOSITORYOptionalA 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.

Back to top ↑

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

Shell
th container images delete IMAGE [--quiet]

An image a Container runs cannot be deleted. --quiet skips the prompt.

Examples

Remove a tag

Shell
th container images delete api:old-tag

Remove an image and all its tags by digest

Shell
th container images delete api@3f2c9a1

Positional arguments

NameDescription
IMAGERequiredREPOSITORY: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.

Back to top ↑

th container images delete-repository

Deletes a repository with all its images and tags.

Syntax

Shell
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

Shell
th container images delete-repository old-worker

Positional arguments

NameDescription
REPOSITORYRequiredA 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.

Back to top ↑

th builds list

Lists the Project's latest 100 builds, Containers and Functions alike, newest first.

Syntax

Shell
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

Shell
th builds list --status active

Function builds that failed

Shell
th builds list --kind function --status failed

The latest 100 builds, Containers and Functions

Shell
th builds list

Only builds into api

Shell
th builds list --repository api

Parameters

NameTypeDefaultDescription
--statusstringOnly builds that are active (queued or running), queued, running, succeeded, failed or cancelled
--kindstringOnly container or function builds
--repositorystringOnly builds into this repository

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th builds log

Prints a build's log; --follow keeps printing until the build ends.

Syntax

Shell
th builds log ID [--follow]

Examples

Follow a build until it ends

Shell
th builds log <build-id> --follow

Positional arguments

NameDescription
IDRequiredThe build ID, as printed by th container deploy or th builds list.

Parameters

NameTypeDefaultDescription
--followflagKeep printing until the build ends

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th builds cancel

Stops a queued or running build.

Syntax

Shell
th builds cancel ID

Examples

Stop a queued or running build

Shell
th builds cancel <build-id>

Positional arguments

NameDescription
IDRequiredThe 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.

Back to top ↑