How to create custom app?

I am trying to create custom app on my scale eel install, and it simply does not work. App I wish to install works with two containers and I can not see how can I make two containers start and work with each other (and my main one to be visible from the network).

I have tried to create custom app (from gui) and it appears that current state of gui does not allow that kind of configuration at all.

Second, I have tried to create app with my own yaml file, but this fails as well and I do not understand what I am missing. I have tried to look at the documentation as well as forum posts but no success (my conclusion is that truenas docker appears to work differently for expected docker config).

I have also tried to find sample yaml from catalogued apps (it should be somewhere), but I was unable to find it (looked in .ix-apps folder, there are some of the files but nothing I found useful to reconstruct on what I am supposed to do).

Here is a sample (this is from containers/bitnami/wordpress/docker-compose.yml at main · bitnami/containers · GitHub):

# Copyright Broadcom, Inc. All Rights Reserved.
# SPDX-License-Identifier: APACHE-2.0

services:
  mariadb:
    image: docker.io/bitnami/mariadb:latest
    volumes:
      - 'mariadb_data:/bitnami/mariadb'
    environment:
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=bn_wordpress
      - MARIADB_DATABASE=bitnami_wordpress
  wordpress:
    image: docker.io/bitnami/wordpress:6
    ports:
      - '80:8080'
      - '443:8443'
    volumes:
      - 'wordpress_data:/bitnami/wordpress'
    depends_on:
      - mariadb
    environment:
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
      - WORDPRESS_DATABASE_HOST=mariadb
      - WORDPRESS_DATABASE_PORT_NUMBER=3306
      - WORDPRESS_DATABASE_USER=bn_wordpress
      - WORDPRESS_DATABASE_NAME=bitnami_wordpress
volumes:
  mariadb_data:
    driver: local
  wordpress_data:
    driver: local

What I can do is that if I remove second container (in this case wordpress), I can sucessfully create and run first one (mariadb).

Any ideas, suggestions on how to create successfull yaml file which will start and run this yaml? Or someone willing to make this yaml work on their scale?

p.s. I think we/someone should create working sample/template for whole community to experiment with it
p.p.s. I saw some of the yt videos which include dockge but I think that simple config with yaml should be enough (and likely preffered option)

if you’re just pasting in this yaml your storage paths are totally wrong.

before pasting this yaml in you’d have to create two datasets,one for the wordpress data and one for the mariadb data. Then you have to adjust the storage paths in the yaml to match the paths to the datasets you created.

example for a valid storage paths would be:

/mnt/Poolname/Datasetname/wordpress:/config
/mnt/Poolname/Datasetname/mariadb:/config
4 Likes

In addition to the path issue, there’s also the port issue–this compose file wants ports 80 and 443, which are taken by default by the TrueNAS UI. You’ll need to change one or the other (or possibly both) of those port configurations.

But to your broader question of “how to use a compose file that creates more than one container,” there’s absolutely nothing in TrueNAS that makes this any different than in any other compose environment. If you’re having trouble, what? What error are you getting?

Edit: This Compose works just fine:

# Copyright Broadcom, Inc. All Rights Reserved.
# SPDX-License-Identifier: APACHE-2.0

services:
  mariadb:
    image: docker.io/bitnami/mariadb:latest
    volumes:
      - /mnt/tank/test/mariadb:/bitnami/mariadb
    environment:
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=bn_wordpress
      - MARIADB_DATABASE=bitnami_wordpress
  wordpress:
    image: docker.io/bitnami/wordpress:6
    ports:
      - '8080:8080'
      - '8443:8443'
    volumes:
      - /mnt/tank/test/wordpress:/bitnami/wordpress
    depends_on:
      - mariadb
    environment:
      # ALLOW_EMPTY_PASSWORD is recommended only for development.
      - ALLOW_EMPTY_PASSWORD=yes
      - WORDPRESS_DATABASE_HOST=mariadb
      - WORDPRESS_DATABASE_PORT_NUMBER=3306
      - WORDPRESS_DATABASE_USER=bn_wordpress
      - WORDPRESS_DATABASE_NAME=bitnami_wordpress

The differences are the two that Lars and I have mentioned: the volumes point to actual paths on the pool rather than Docker volumes, and the ports are changed so as to not conflict with the web UI.

I set permissions on /mnt/tank/test/mariadb to 777 to address a permissions issue; it looks like this particular Mariadb container wants to use user 1001, so it’d be better to change ownership to that instead.

2 Likes

It works with modified yaml (as per your instructions). Thanks!

There are few differences between yaml which I posted and this one, differencers are mainly in definition of volumes. I have corrected the path and now it works (I expected that it will make its own volumes within /mnt/.ix-app folders).

I needed to add +777 for both volumes in order for them to work (I also added PUID i PGID of 0 in mariadb container in attempt to avoid using user 1001 - btw. how did you figure it out that it looks for userid 1001).

Now I only have to figure out why app_lifecycle.log is empty (there was a lot of my errors in it and I deleted it to remove clutter, and now it remains empty).

Now to more complex apps :slight_smile:

When I set its data directory to permissions of 777, the directory it created was owned by 1001.

If you use dockers “volume” functionality, docker makes volumes in the docker directory, which is mounted there.

I would suggest not using the volume functionality and instead bind mounting host paths.

As suggested already

1 Like

I did exactly that and it works nicely (I thought I could get away without it, but generally I would agree that this/your approach is much better for housekeeping).

The configuration with YAML is the same whether you’re using Dockge or EE’s built-in “custom app” functionality. Dockge gives you some additional flexibility, and also writes the compose files to disk, which can be helpful in some circumstances. But there really isn’t any difference in how you’d prepare the YAML between these.

IOW, the reason that this doesn’t exist:

is because it’s simple Compose. That’s the entire point (or at least much of the point) of going to Compose. There’s just nothing unique to TrueNAS about it, and thus there’s really no reason for such a thing.

1 Like