Build a
Docker Image Locally, Push It to Artifact Registry and Run It on Container Apps
Build an image with Docker on your own machine, log in to XVer Artifact Registry, push it, and run it on Container Apps at a public URL, then ship new versions and roll back
On this page
- How an image travels from your machine to the web
- 1. Get the sample app
- 2. Test it on your machine first
- 3. Find your project name and registry password
- 4. Log in to the registry from your machine
- 5. Build for linux/amd64 and push
- 6. Save a credential for Container Apps
- 7. Deploy on Container Apps
- 8. Change the code and ship a new version
- What it costs
- Troubleshooting
- FAQ
You can build a Docker image on your own machine and docker push it straight to XVer Artifact Registry at artifact.xver.cloud. Container Apps then pulls that image and runs it as a website with a ready-to-use HTTPS URL, with no GitHub connection and no server of your own.
How an image travels from your machine to the web#
- Write the code and a Dockerfile on your machine
- docker build makes an image for amd64 servers
- docker push uploads it to Artifact Registry, into your project
- Container Apps pulls the image with a saved credential
- You get an HTTPS URL that opens from anywhere
Before you start
1. Get the sample app#
Download the sample app (.zip) and unzip it, or create a folder named hello-xver with the four files below. You do not need Go installed, because the compile step runs inside Docker.
- hello-xver/
- main.go
- go.mod
- Dockerfile
- .dockerignore
The app is a small web server. The home page shows its version, and /healthz answers with JSON so you can check that it runs.
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"
)
// version is set at build time: docker build --build-arg VERSION=1.0.0
var version = "dev"
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
host, _ := os.Hostname()
mux := http.NewServeMux()
mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintf(w, "<!doctype html><meta charset=utf-8><title>hello-xver</title>"+
"<h1>Hello from XVer</h1><p>version %s</p><p>instance %s</p>", version, host)
})
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]any{
"ok": true,
"version": version,
"time": time.Now().UTC().Format(time.RFC3339),
})
})
srv := &http.Server{Addr: ":" + port, Handler: mux, ReadHeaderTimeout: 5 * time.Second}
go func() {
log.Printf("hello-xver %s listening on :%s", version, port)
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Fatal(err)
}
}()
// Stop cleanly when the platform scales the instance down.
stop := make(chan os.Signal, 1)
signal.Notify(stop, syscall.SIGTERM, os.Interrupt)
<-stop
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
srv.Shutdown(ctx)
log.Print("stopped")
}module hello-xver
go 1.26# Stage 1: compile with Go on the machine's own architecture, output for the target one
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS build
ARG TARGETOS
ARG TARGETARCH
ARG VERSION=dev
WORKDIR /src
COPY go.mod main.go ./
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o /out/app .
# Stage 2: only the program, nothing else
FROM scratch
COPY --from=build /out/app /app
USER 65534:65534
EXPOSE 8080
ENTRYPOINT ["/app"].git
*.md
*.zipThree parts of this Dockerfile are worth knowing, because they carry over to apps in other languages.
Multi-stage build
The first stage uses a full Go image to compile. The second starts from an empty scratch image and copies in only the program, so the final image is small, pushes quickly and takes little registry space.
Cross-compiling
The first FROM line uses $BUILDPLATFORM, so the compile stage runs on your machine's own architecture, and Go writes a binary for TARGETARCH. On an Apple Silicon Mac nothing has to emulate another CPU during the build.
Reads PORT and does not run as root
Container Apps passes the port in the PORT variable, so the app reads it first and falls back to 8080. USER 65534 keeps the program from running with root rights.
2. Test it on your machine first#
Go into the hello-xver folder, then build and run it for your machine's own architecture. This step does not use the registry name yet.
docker build -t hello-xver:dev .
docker run --rm -p 8080:8080 hello-xver:devOpen http://localhost:8080 in a browser, or call /healthz from a second terminal window.
curl http://localhost:8080/healthz3. Find your project name and registry password#
Open Artifact Registry in the console. The name in the Project box is the second part of every image name you push, as in artifact.xver.cloud/<project>/hello-xver.


Click Authentication (การยืนยันตัวตน in the Thai console) to see the login command, your username, which is your XVer email, and the password reset button.


- Copy the username with the copy icon next to Username.
- Get a password. If you have no saved registry password, click Reset password and confirm.
- Store it right away. The next window shows the new password only once. Copy it into your password manager, tick I've saved this password somewhere safe, then click Close.
Fill in your values below and every command on this page uses them.
Type your own values and the commands on this page follow
4. Log in to the registry from your machine#
docker login artifact.xver.cloud -u EMAILDocker asks for the password. Paste the one from step 3 and press Enter (nothing appears on screen while you type, which is normal).
5. Build for linux/amd64 and push#
Container Apps runs linux/amd64 images. On an Apple Silicon Mac a plain docker build makes an arm64 image that cannot run on the server, so always pass --platform linux/amd64 (it does no harm on x86 Windows or Linux machines either).
The four parts of an image name
- Registry
artifact.xver.cloud- Project
your project name (
PROJECT)- App name (repository)
your choice, in lowercase, such as
hello-xver- Tag
the image version, such as
1.0.0orlatest
Build version 1.0.0, then check that it really is linux/amd64.
docker buildx build --platform linux/amd64 --build-arg VERSION=1.0.0 -t artifact.xver.cloud/PROJECT/hello-xver:1.0.0 --load .
docker image inspect artifact.xver.cloud/PROJECT/hello-xver:1.0.0 --format '{{.Os}}/{{.Architecture}}'The second command must print linux/amd64. Then give the same image the latest tag as well and push both tags.
docker tag artifact.xver.cloud/PROJECT/hello-xver:1.0.0 artifact.xver.cloud/PROJECT/hello-xver:latest
docker push artifact.xver.cloud/PROJECT/hello-xver:1.0.0
docker push artifact.xver.cloud/PROJECT/hello-xver:latestClick Refresh on the Artifact Registry page and open the Repositories tab. Your new app is listed with its docker pull command.


Why push two tags? The version tag records exactly what each release shipped and is what you roll back to. latest is the tag your app on Container Apps follows.
A version tag such as 1.0.0Use every time
The same name always points to the same image, so you know exactly which code runs, can roll back at once, and can see the history in the Repositories tab.
latest
A tag that moves to the new image on every push. Handy when the app should pull the newest build, but the name alone does not tell you which version of the code it is.
6. Save a credential for Container Apps#
Images in Artifact Registry are private: nobody can pull them without logging in, Container Apps included. So save your username and password once as a credential.


- Open the Credentials tab on the Container Apps page and click New credential.
- Fill in the form: name
xver-registry, registry endpointartifact.xver.cloud, your email as the username and your registry password. - Click Create credential. A new row appears in the table with a Copy ID button for xverctl.
7. Deploy on Container Apps#
On the Container Apps page of the console, click Deployment to start. The form has three steps: Source, Configuration and Review & deploy.


| Field | Value | Note |
|---|---|---|
| Service name | hello-xver |
Lowercase letters, digits and hyphens |
| Pricing model | Request-based | Billed by real usage; it cannot be changed later |
| Source | Container image | |
| Container image | artifact.xver.cloud/PROJECT/hello-xver |
Leave out the :tag |
| Image tag | latest |
The tag the app follows |
| Registry credential | xver-registry |
With None (public image) the image cannot be pulled |
| Image pull policy | Always | Pulls latest again each time the app starts |
On the configuration step keep Container port at 8080 to match the app, and set CPU (m) to 250 and Memory (MB) to 512, which is plenty for the sample. Do not add a PORT variable yourself; the platform sets it from the container port.
On the review step check everything, accept the terms and click Deploy container. You land on the app page. When the status is Running, copy the Default URL from the Overview tab, put only the host into the APP_HOST box above, and call it.
curl https://APP_HOST/healthz8. Change the code and ship a new version#
Change the Hello from XVer text in main.go, then build version 1.0.1, move the latest tag to it and push both tags.
docker buildx build --platform linux/amd64 --build-arg VERSION=1.0.1 -t artifact.xver.cloud/PROJECT/hello-xver:1.0.1 --load .
docker tag artifact.xver.cloud/PROJECT/hello-xver:1.0.1 artifact.xver.cloud/PROJECT/hello-xver:latest
docker push artifact.xver.cloud/PROJECT/hello-xver:1.0.1
docker push artifact.xver.cloud/PROJECT/hello-xver:latestA push alone does not change the running app. Tell the app to start a new revision in one of these ways.
Console
Open the hello-xver app page, click More actions (the three dots) at the top right, and choose Restart. The platform starts a fresh copy that pulls the newest latest image and switches traffic once it is ready.


xverctl
xverctl switches the app to a given tag in one command and waits until it is ready.
xverctl container redeploy hello-xver --tag 1.0.1 --waitAfter this the app follows 1.0.1 instead of latest, so pass the new version with --tag each time.
If the new version misbehaves, go back to one you trust.
docker pull --platform linux/amd64 artifact.xver.cloud/PROJECT/hello-xver:1.0.0
docker tag artifact.xver.cloud/PROJECT/hello-xver:1.0.0 artifact.xver.cloud/PROJECT/hello-xver:latest
docker push artifact.xver.cloud/PROJECT/hello-xver:latestThen click Restart again, or run xverctl container redeploy hello-xver --tag 1.0.0 --wait, which leaves latest alone.
First deploy with xverctl instead of the console
Copy the ID of the xver-registry credential from the Credentials tab (the Copy ID button), then run:
xverctl container deploy hello-xver --image artifact.xver.cloud/PROJECT/hello-xver --tag 1.0.0 --registry-credential CREDENTIAL_ID --port 8080 --cpu 250 --memory 512 --waitWhen it finishes, xverctl prints the app with its URL. Read recent logs with xverctl container logs hello-xver --tail 100. Creating the credential and resetting the registry password are still done in the console.
What it costs#
Artifact Registry charges for the space your images actually use, metered hourly per project and taken from your account credit.
Image storage pricing
- Free
the first 0.5 GB
- Above that
฿0.0042 per GB per hour (about ฿3.07 per GB per month)
- How it is worked out
(GB used − 0.5 GB) × the hourly rate, deducted from credit every hour
The sample image in this guide is about 3 MB per version once compressed, so dozens of versions still fit in the free space.
Images in other languages can be hundreds of MB per version. Set a Retention policy on the Artifact Registry page to keep only the latest N versions, and older ones are removed for you. Running the app on Container Apps is billed by vCPU, memory and requests, with a monthly free allowance; see the rates on Container Apps pricing.
Troubleshooting#
Login and push problems
Issuedocker login says unauthorized
The email or password is wrong, or the password was reset. The username must be the same email shown in the Authentication window. If you lost the password, reset it and log in again.
Issuedocker push says denied or unauthorized to access repository
You have not logged in on this machine, or the project in the image name is wrong. Check that the second part of the image name matches the Project box exactly.
Issuedocker push says An image does not exist locally with the tag
The name you push differs from the name you built. Run docker images to see what exists, then docker tag it to the right name first.
Deploy errors show on the app page. The program's own log is in the Logs tab, which opens while the app is running.
Deploy and runtime problems
IssueDeploy fails with authentication failed or unable to pull image
No credential was chosen in the Registry credential field, or the credential still holds the password from before a reset. Fix it on the Credentials tab and deploy again.
IssueDeploy fails with image not found in registry
The image name or tag does not match what you pushed. Open the Repositories tab and copy the name from its docker pull command, and put the tag in the Image tag field, not in the image name.
IssueThe log shows exec format error
The image was built as arm64 on an Apple Silicon Mac. Build again with --platform linux/amd64, confirm linux/amd64 with docker image inspect, and push over it.
If the image pulls but the app never reaches Running, the most common cause is the port.
Port problems
IssueStatus hangs and then fails, although the log says the app started
The app listens on a port other than Container port. Have the app read the PORT variable and listen on all interfaces (:8080 or 0.0.0.0:8080, not 127.0.0.1:8080), or change Container port on the Settings tab to match the app.
IssueThe form says the PORT variable cannot be set
PORT is set by the platform. Remove the PORT row from the environment variables and change the port in the Container port field instead.
FAQ#
Are images in XVer Artifact Registry public?
No. Images in your project are private. You must log in with your email and registry password to pull or push, which is why Container Apps needs a saved credential.
Can I use
Docker Hub or
GHCR instead of Artifact Registry?
Yes. The Container image field takes images from other registries too; add a credential for that registry if the image is private. Artifact Registry keeps the image in Thailand next to your app and in the same console.
Do I have to build for linux/amd64 every time?
Yes. Container Apps runs linux/amd64 images, and an Apple Silicon Mac builds arm64 unless you pass --platform linux/amd64.
I don't want to build on my machine. Is there another way?
Yes. Container Apps can build from a GitHub repository for you; see Build a Telegram Bot with
Node.js on Container Apps. Building locally suits people who want to see and control the exact image before it goes live.