Feature #23051 » nginx-example.md
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.
- Create a collection with HTML and/or other files you want to serve with nginx.
- Upload the nginx container to your cluster:
arv-keepdocker nginx 1.29.0
For me the resulting collection had PDHab05d69dc0dd17884f01e330a11402a7+219and 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. - Create this container request JSON with the following edits:
- Set
owner_uuidto the project where it should run. - Under
mounts, setuuidto the UUID of the collection you want to serve. (Alternatively, you can replaceuuidwithportable_data_hash.) - If you got a different PDH for the Docker image, set that as
container_image. - If you want the service to start on a page other than
index.html, underpublished_ports, set that asinitial_path. - Adjust the
runtime_constraintsif you want.APImust betrueto enable container networking.
- Set
{
"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
}
- Submit this to Arvados by running (on a system with the
arvados-cligem):
arv container_request create -o YOUR_NGINX.json
That should output a full container request with acontainer_uuid. - Using that
container_uuid, run:
arv container get --uuid=zzzzz-dz642-12345abcde67890
Underpublished_ports, there should be aninitial_url. That is the URL for nginx you should be able to open in a browser. (If there is noinitial_urlyet, 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.)