Deploy Docker Using REST API

This tutorial demonstrates how to deploy a Docker job using the Apcera REST API.

Instructions

  1. Target your cluster log in using APC.

  2. Open the .apc file using a text editor.

  3. Copy the Bearer token to a temporary file.

  4. Create the JSON application payload.

    Copy the JSON below to a text file named deis.json and save it to a known local direcctory. Update the SUBDOMAIN in the "routes" URL to match your cluster and, if necessary, the "job_fqn" to match your default namespace where you have policy.

     {
       "allow_egress":true,
       "exposed_ports":[
         80
       ],
       "image_url":"https://registry-1.docker.io/deis/helloworld:latest",
       "job_fqn":"job::/sandbox/admin::deisdocker",
       "resources":{
         "cpu":0,
         "disk":1073741824,
         "memory":268435456,
         "netmax":0,
         "network":5000000
       },
       "restart_config":{
         "maximum_attempts":0,
         "restart_mode":"no"
       },
       "routes":{
         "http://deisdocker.SUBDOMAIN.apcera-platform.io":80
       },
       "start":true
     }
    
  5. Deploy the Docker job using cURL.

    CD to where you saved the desi.json file. Provide the Bearer token and update the SUBDOMAIN in the URL.

     curl -X POST --data "@deis.json" -H "Content-Type: application/json" -H "Authorization: Bearer <token>" "http://api.SUBDOMAIN.apcera-platform.io/v1/jobs/docker"
    
  6. Verify the response.

    A successful POST returns a "location" object with the UUID for the job. For example:

     {"location":"http://api.SUBDOMAIN.apcera-platform.io/v1/tasks/7f3a53d0-bb81-4e00-9102-e1dc1dff48b3"}
    
  7. Check the status of the Docker job.

    Do a GET on the "tasks" endpoint with the UUID of the job. For example:

     curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer <token>" "http://api.SUBDOMAIN.apcera-platform.io/v1/tasks/7f3a53d0-bb81-4e00-9102-e1dc1dff48b3"
    
  8. Verify deployment by going to the route URL with a browser.