Deploy your first app
Deploy a public container image, open it at its default URL, read what the deployment did, and delete it again, in about ten minutes.
The tutorial runs the public image docker.io/library/nginx:1.27-alpine, which listens on port 80. Replace app-id with the id the create step returns, and deployment-id with the
id the deploy step returns.
Prerequisites
- Permission for
deploy:CreateApp,deploy:DeployApp,deploy:DescribeAppanddeploy:DeleteApp. TheAdministratorAccesspolicy has them. - For the CLI:
dcloudinstalled and signed in.
Important
The first deployment creates a machine, and you pay for it per started hour until you delete the app in Clean up.
Step 1: Create the app
- Open Apps, then choose Create app.
- Under What to run, choose A container image.
- If your registry already holds images, for Image from, choose From somewhere else.
- For Image reference, enter
docker.io/library/nginx:1.27-alpine. - Choose Continue.
- For Name, enter my-app.
- For Container port, keep
80. The console sets it for an nginx image; for another image, enter the port it listens on (the console's default is8080). - For Machine size, keep the default, then choose Continue.
- Under Rollout, keep Deploy immediately selected. Cleared, the app is created without a deployment.
- Choose Create and deploy. The app page opens and the first deployment starts.
dcloud deploy apps create --name my-app --builder image \
--image-ref docker.io/library/nginx:1.27-alpine --port 80The answer holds the app's id.
POST /deploy/api/apps
{ "name": "my-app", "builder": "image", "imageRef": "docker.io/library/nginx:1.27-alpine", "port": 80 }The answer holds the app's id.
Step 2: Deploy it and wait
- Open the app's Deployments tab. Activity lists each step as it happens: the machine being created, the image pulled, the health check, the domain moved.
- Wait until the status reads Live. A first deployment installs the machine and takes a few minutes.
dcloud deploy apps deploy app-id --waitThe command prints the deployment's activity as it happens and exits 0 once it is live.
POST /deploy/api/apps/3f1c2b4a-5d6e-4f70-8a91-b2c3d4e5f601/deployments
{ "trigger": "manual" }Then call GET /deploy/api/deployments/deployment-id/wait?timeoutSec=55 until the answer
has terminal: true.
Step 3: See it live
- On the app page, choose Open. The nginx welcome page loads at the app's default URL, over HTTPS.
dcloud deploy apps get app-idThe answer names the default URL. Open it in a browser.
GET /deploy/api/apps/app-id names the default URL; GET /deploy/api/deployments/deployment-id/events returns the activity you saw in the console.
Clean up
Delete the app so that its machine stops costing money.
- Open the app's Danger zone tab.
- Choose Delete app, enter the app's name to confirm, and confirm. The app list shows it as deleting until everything it created is gone.
dcloud deploy apps delete app-id --yesDELETE /deploy/api/apps/app-id answers 202 with status: "deleting".