Skip to content

Instantly share code, notes, and snippets.

@thoroc
Last active May 30, 2025 04:49
Show Gist options
  • Save thoroc/2556d40339777ee13add79a7d0eb4310 to your computer and use it in GitHub Desktop.
Save thoroc/2556d40339777ee13add79a7d0eb4310 to your computer and use it in GitHub Desktop.
Docker in Incus is Awesome - The “Get my” application (Aug 2024)

Deploying the “Get my” Application with Incus OCI Containers

Overview

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


Prerequisites

Ensure that Incus 6.3 or newer is installed:

incus version

Add the Docker image repository if it has not been added previously:

incus remote add docker https://docker.io

Reference: Original Docker Compose Configuration

For 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-stopped

Incus OCI currently does not support links, depends_on, or restart directives. These aspects are handled differently, as explained below.

Step-by-Step Deployment

1. Create the MongoDB Container

incus create docker:mongo:4.4 get-my-db

Creates a MongoDB container named get-my-db without starting it.

 2. Create the Application Container

incus create docker:bmcgonag/get_my:latest get-my -c environment.MONGO_URL=mongodb://get-my-db

environment.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:
  - mongo

3. Create a Persistent Volume for MongoDB

Create a folder on the Incus host to store persistent MongoDB data:

mkdir ~/get-my-data

Add 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=true
  • source must be an absolute path.
  • shift=true ensures proper UID/GID mapping between host and container.

This configuration is equivalent to the following Docker Compose volume directive:

volumes:
  - ./data:/data/db

4. Configure Network Access to the App

Expose 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"
  • connect refers to the internal container port (cannot be changed).
  • listen defines 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.

5. Start the Containers

Start the MongoDB container:

incus start get-my-db

Verify running containers:

incus list

Then start the application container:

incus start get-my

6. Access the Application

Determine the Incus host’s IP address using:

ifconfig

Then access the application in a web browser at:

http://<host-ip>:3000

Updating the Application

To upgrade the get-my container when a new version is released:

  1. Stop the container:
incus stop get-my
  1. Rebuild the container using the latest image::
incus rebuild docker:bmcgonag/get_my:latest get-my

Equivalent to the Docker command:

docker compose pull
  1. Start the container:
incus start get-my

Optional: Enable Autostart

To ensure the container starts automatically with the host:

-c boot.autostart=true

This configuration can be set during container creation or applied via incus config set.

Summary

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment