This guide explains how to deploy the Get my application using
Incus with the new OCI container support introduced in Incus 6.3.
Get my is a lightweight web application for managing shared family task and shopping lists, created by Brian (Open
Source Advocate).
For users new to Incus, refer to the introductory tutorial:
➡️ Incus Containers Step by Step
Previous demonstrations of Incus OCI container deployment include applications such as Draw.IO and the
Ghost blogging platform:
➡️ Incus Docker Containers
Ensure that Incus 6.3 or newer is installed:
incus versionAdd the Docker image repository if it has not been added previously:
incus remote add docker https://docker.ioFor comparison purposes, the original deployment used the following docker-compose.yml:
services:
get_my:
container_name: get_my
image: bmcgonag/get_my
ports:
- "3000:3000"
healthcheck:
test: curl --fail -s http://localhost:3000/ || exit 1
interval: 30s
timeout: 10s
retries: 3
links:
- mongo
depends_on:
- mongo
restart: unless-stopped
mongo:
container_name: get_my-mongo
image: mongo:4.4
volumes:
- ./data:/data/db
restart: unless-stoppedIncus OCI currently does not support
links,depends_on, orrestartdirectives. These aspects are handled differently, as explained below.
incus create docker:mongo:4.4 get-my-dbCreates a MongoDB container named get-my-db without starting it.
incus create docker:bmcgonag/get_my:latest get-my -c environment.MONGO_URL=mongodb://get-my-dbenvironment.MONGO_URL instructs the application to connect to the database container named get-my-db, which is resolvable
as a DNS hostname within the Incus network.
Multiple environment variables can be passed using multiple -c environment.* flags.
This is functionally equivalent to the following in Docker Compose:
links:
- mongoCreate a folder on the Incus host to store persistent MongoDB data:
mkdir ~/get-my-dataAdd the volume to the MongoDB container:
incus config device add get-my-db mongodb disk source=/home/scott/get-my-data path=/data/db shift=truesourcemust be an absolute path.shift=trueensures proper UID/GID mapping between host and container.
This configuration is equivalent to the following Docker Compose volume directive:
volumes:
- ./data:/data/dbExpose port 3000 to the host network using a proxy device:
incus config device add get-my hostport3000 proxy connect="tcp:127.0.0.1:3000" listen="tcp:0.0.0.0:3000"connectrefers to the internal container port (cannot be changed).listendefines the external port accessible on the host.
This is equivalent to the following Docker Compose port mapping:
ports:
- "3000:3000"Ensure that the chosen port is not in use by another service.
Start the MongoDB container:
incus start get-my-dbVerify running containers:
incus listThen start the application container:
incus start get-myDetermine the Incus host’s IP address using:
ifconfigThen access the application in a web browser at:
http://<host-ip>:3000To upgrade the get-my container when a new version is released:
- Stop the container:
incus stop get-my- Rebuild the container using the latest image::
incus rebuild docker:bmcgonag/get_my:latest get-myEquivalent to the Docker command:
docker compose pull- Start the container:
incus start get-myTo ensure the container starts automatically with the host:
-c boot.autostart=trueThis configuration can be set during container creation or applied via incus config set.
This deployment demonstrates the use of Incus’s new OCI container support to run a Dockerized web application (Get my)
natively within Incus, with proper environment variables, persistent volumes, and network access. As Incus OCI continues
to evolve, support for additional Docker Compose features is expected to improve.
Refer to the official Incus documentation for further details.
Source: https://discussion.scottibyte.com/t/docker-in-incus-is-awesome-the-get-my-application/457