Project

General

Profile

Feature #23051 » nginx-example.md

Brett Smith, 07/16/2025 03:33 PM

 

Example Service Container

This is a simple demo of running nginx inside a service container to serve static content from a container. I hope this is simple enough that it illustrates how to fit the different pieces together.

NOTE: This might require a controller patch that Brett wrote on 2025-07-15.

  1. Create a collection with HTML and/or other files you want to serve with nginx.
  2. Upload the nginx container to your cluster:
    arv-keepdocker nginx 1.29.0
    For me the resulting collection had PDH ab05d69dc0dd17884f01e330a11402a7+219 and that’s reflected below. If you got a different PDH (the image might have newer libraries underneath?), you’ll need to replace this PDH where it appears.
  3. Create this container request JSON with the following edits:
    1. Set owner_uuid to the project where it should run.
    2. Under mounts, set uuid to the UUID of the collection you want to serve. (Alternatively, you can replace uuid with portable_data_hash.)
    3. If you got a different PDH for the Docker image, set that as container_image.
    4. If you want the service to start on a page other than index.html, under published_ports, set that as initial_path.
    5. Adjust the runtime_constraints if you want. API must be true to enable container networking.
{  
  "name": "nginx server",  
  "owner_uuid": "zzzzz-j7d0g-12345abcde67890",  
  "container_image": "ab05d69dc0dd17884f01e330a11402a7+219",  
  "mounts": {  
    "/usr/share/nginx/html": {  
      "kind": "collection",  
      "uuid": "zzzzz-4zz18-12345abcde67890"  
    },  
    "/run/nginx.out": {  
      "kind": "collection",  
      "writable": true  
    }  
  },  
  "runtime_constraints": {  
    "ram": 209715200,  
    "vcpus": 2,  
    "API": true  
  },  
  "published_ports": {  
    "80": {  
      "access": "public",  
      "label": "nginx web server",  
      "initial_path": ""  
    }  
  },  
  "cwd": ".",  
  "command": [  
    "nginx",  
    "-g",  
    "daemon off;"  
  ],  
  "output_path": "/run/nginx.out",  
  "state": "Committed",  
  "priority": 499,  
  "service": true,  
  "use_existing": false  
}
  1. Submit this to Arvados by running (on a system with the arvados-cli gem):
    arv container_request create -o YOUR_NGINX.json
    That should output a full container request with a container_uuid.
  2. Using that container_uuid, run:
    arv container get --uuid=zzzzz-dz642-12345abcde67890
    Under published_ports, there should be an initial_url. That is the URL for nginx you should be able to open in a browser. (If there is no initial_url yet, the container hasn’t been dispatched yet. Wait a moment and try again. If it’s taking too long to dispatch, you’ll need to investigate in the Crunch logs.)
    (1-1/1)