summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/container-bundling.md95
1 files changed, 95 insertions, 0 deletions
diff --git a/docs/container-bundling.md b/docs/container-bundling.md
index 745622b5..f4587a99 100644
--- a/docs/container-bundling.md
+++ b/docs/container-bundling.md
@@ -360,6 +360,101 @@ Containers can be configured to start automatically on boot:
360- Podman: `/etc/containers/systemd/<name>.container` (Quadlet format) 360- Podman: `/etc/containers/systemd/<name>.container` (Quadlet format)
361 361
362 362
363Custom Service Files
364--------------------
365
366For containers that require specific startup configuration (ports, volumes,
367capabilities, dependencies), you can provide custom service files instead of
368using the auto-generated ones.
369
370### Variable Format
371
372Use the `CONTAINER_SERVICE_FILE` varflag to specify custom service files:
373
374 CONTAINER_SERVICE_FILE[container-name] = "${UNPACKDIR}/myservice.service"
375 CONTAINER_SERVICE_FILE[other-container] = "${UNPACKDIR}/other.container"
376
377### For BUNDLED_CONTAINERS (in image recipe)
378
379 # host-image.bb or local.conf
380 inherit container-cross-install
381
382 SRC_URI += "\
383 file://myapp.service \
384 file://mydb.container \
385 "
386
387 BUNDLED_CONTAINERS = "\
388 myapp-container:docker:autostart \
389 mydb-container:podman:autostart \
390 "
391
392 # Map containers to custom service files
393 CONTAINER_SERVICE_FILE[myapp-container] = "${UNPACKDIR}/myapp.service"
394 CONTAINER_SERVICE_FILE[mydb-container] = "${UNPACKDIR}/mydb.container"
395
396### For container-bundle Packages
397
398 # my-bundle_1.0.bb
399 inherit container-bundle
400
401 SRC_URI = "\
402 file://myapp.service \
403 file://mydb.container \
404 "
405
406 CONTAINER_BUNDLES = "\
407 myapp-container:autostart \
408 mydb-container:autostart \
409 "
410
411 CONTAINER_SERVICE_FILE[myapp-container] = "${UNPACKDIR}/myapp.service"
412 CONTAINER_SERVICE_FILE[mydb-container] = "${UNPACKDIR}/mydb.container"
413
414### Docker .service Example
415
416 # myapp.service
417 [Unit]
418 Description=MyApp Container
419 After=docker.service
420 Requires=docker.service
421
422 [Service]
423 Type=simple
424 Restart=unless-stopped
425 RestartSec=5s
426 ExecStartPre=-/usr/bin/docker rm -f myapp
427 ExecStart=/usr/bin/docker run --rm --name myapp \
428 -p 8080:80 \
429 -v /data/myapp:/var/lib/myapp:rw \
430 --cap-add NET_ADMIN \
431 myapp:latest
432 ExecStop=/usr/bin/docker stop myapp
433
434 [Install]
435 WantedBy=multi-user.target
436
437### Podman .container (Quadlet) Example
438
439 # mydb.container
440 [Unit]
441 Description=MyDB Container
442
443 [Container]
444 Image=mydb:latest
445 ContainerName=mydb
446 PublishPort=5432:5432
447 Volume=/data/db:/var/lib/postgresql/data:Z
448 Environment=POSTGRES_PASSWORD=secret
449
450 [Service]
451 Restart=unless-stopped
452 RestartSec=5s
453
454 [Install]
455 WantedBy=multi-user.target
456
457
363vdkr and vpdmn - Virtual Container Runtimes 458vdkr and vpdmn - Virtual Container Runtimes
364=========================================== 459===========================================
365 460