Create your first compose file

Start with the developers compose file

In this section we will create a compose file for the Omnitools apparrow-up-right

  1. Open your GitHub repo and enter the docker-compose folder

  2. Click on 'Add file' > 'Create new file'

  3. Name the file 'omnitools.yml', and copy the compose file from herearrow-up-right It should look something like this:

    services:
      omni-tools:
        image: iib0011/omni-tools:latest
        container_name: omni-tools
        restart: unless-stopped
        ports:
          - "8080:80"
  4. Hit 'Commit changes...'

  5. hit 'Commit changes'

    1. If you care, write some information about what you are doing

  6. Navigate to your file and review its contents

Update the compose file

Copy and pasting other peoples compose files is great and all, but you are best to learn how to write and edit them yourself.

Variables

To keep your compose files as system agnostic as possible, its best to use variables where you can. Some suggestions are

  • Ports

  • Volume paths

  • Labels

These variables can then be set in Portainer when creating the stack

Health Checks

Some containers come with health checks, some do not. After starting the stack, refer to the state. If it is "running", it does not have an inbuilt health check.

Website

If your app has a web-ui, you can test the below commands

  1. Open up your stack and select the container

  2. Click on the Console button

  3. Attempt each command until you get access to the terminal

    1. Click on the command dropdown and select the first option

    2. Click on connect

    3. Repeat until you have access to the terminal

  4. Once you are connected, try the below commands. If you get "not found" or something similar, move onto the next one

    1. curl

    2. wget

  5. Add the below to your app. Do not forget to update the port

circle-info

You may need to adjust the retries, start period and timeout

Database

Labels

Volumes

Container versioning

Do not use the 'latest' tag, as it does not allow Renovate to update the compose file, and if it automatically updates it may bring braking changes.

When versioning your compose files, locate the 'latest' tag on the DockerHub, GitHub etc and use the relevant version number.

This is harder to do on DockerHub. Per the screenshot below, we've located the 'latest' tag and used the digest version to locate the correct version.

Take note of the OS/ARCH as well - you can see that tag 2.12.5 contains both AMD64 and ARM64 containers, meaning this compose file can be used on both ARM and x86 machines.

Here is my tweaked example

https://github.com/trentnbauer/Homelab/blob/main/docker-compose/omnitools.yml
circle-info

Please note: The dfgeneric labels relate to the Dockflare app - DockFlare (Tunnel management)

Last updated