Skip to content

OCIO y TECnología

  • Privacy Policy
Offcanvas

  • Register
  • Lost your password ?

OCIO y TECnología

  • Home » 
  • Tecnología » 
  • Docker » 
  • Override with an inline entry point on docker-compose.yml

Override with an inline entry point on docker-compose.yml

Emilio González Montaña 2021/04/14 0

This simple post I will demonstrate how to override an entry point with an inline script to any docker-compose.yml.

According to docker compose reference, the default entry point of an image could be overridden, pointing to a file inside the image or defining it inline.

For example, this stack definition defines a CMAK service (administrative UI for Kafka clusters) is based in an image that does not support the usage of _FILE environment variables to use docker secrets, so we define a new multiline entry point with a command (/bin/bash) & a list of arguments, last argument is a pipeline | to indicate YAML file that we want to define several lines (all must be well indented).

Any dollar $ inside the script must be escaped using double dollar $$ to avoid YAML variable replacements.

The docker entry point is based on MariaDB entry point script to parse _FILE variables if present to read its content. Last line of the script is just calling the default CMAK entry point bin/cmak.

version: '3.8'
services:
  cmak:
    image: iunera/cmak:3.0.0.5
    secrets:
      - cmak_password
    environment:
      ZK_HOSTS: zookeeper_1:2181,zookeeper_2:2181,zookeeper_3:2181
      KAFKA_MANAGER_AUTH_ENABLED: 'true'
      KAFKA_MANAGER_USERNAME: admin
      KAFKA_MANAGER_PASSWORD_FILE: /run/secrets/cmak_password
    entrypoint:
      - /bin/bash
      - -c
      - |
        set -eo pipefail
        function file_env {
          local var="$$1"
          local fileVar="$${var}_FILE"
          local def="$${2:-}"
          if [ "$${!var:-}" ] && [ "$${!fileVar:-}" ]; then
            echo "Both $$var and $$fileVar are set, but are exclusive"
            exit 1
          fi
          local val="$$def"
          if [ "$${!var:-}" ]; then
            echo "$$var was defined through environment variable"
            val="$${!var}"
          elif [ "$${!fileVar:-}" ]; then
            echo "$$var was defined through file environment variable $$fileVar"
            val="$$(< "$${!fileVar}")"
          fi
          export "$$var"="$$val"
          unset "$$fileVar"
        }
        file_env 'KAFKA_MANAGER_USERNAME'
        file_env 'KAFKA_MANAGER_PASSWORD'
        bin/cmak
secrets:
  cmak_password:
    external: true
    name: kafka_cmak_password_v1

Comparte esto:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
Tags : Tags CMAK   docker   docker-compose.yml   docker-swarm   Inline   Kafka   MariaDB   override
Share
facebookShare on FacebooktwitterShare on TwitterpinterestShare on Pinterest
linkedinShare on LinkedinvkShare on VkredditShare on ReddittumblrShare on TumblrviadeoShare on ViadeobufferShare on BufferpocketShare on PocketwhatsappShare on WhatsappviberShare on ViberemailShare on EmailskypeShare on SkypediggShare on DiggmyspaceShare on MyspacebloggerShare on Blogger YahooMailShare on Yahoo mailtelegramShare on TelegramMessengerShare on Facebook Messenger gmailShare on GmailamazonShare on AmazonSMSShare on SMS
Post navigation
Previous post

Autumn at Svalbard (2019)

Next post

Auto mount CephFS with autofs

Emilio González Montaña

Related Posts

Categories Linux  Networking  Tecnología Override with an inline entry point on docker-compose.yml

Detachable screens to avoid SSH disconnections

Categories Linux  Networking  Tecnología Override with an inline entry point on docker-compose.yml

Expose WSL2 port to the network

Categories Data bases  Docker  Tecnología Override with an inline entry point on docker-compose.yml

Recover corrupted Postgres DB WAL

Leave a Comment Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Detachable screens to avoid SSH disconnections
  • Expose WSL2 port to the network
  • Rosaleda (parque El Retiro, Madrid)
  • Back to the painting table
  • Recover corrupted Postgres DB WAL

Categories

  • Aficiones
  • AI
  • Bricolage
  • Data bases
  • Docker
  • Escenografía
  • Eventos
  • Fotografía
  • Hardware
  • Linux
  • Networking
  • Partidas
  • Proxmox
  • Sin categoría
  • Tecnología
  • Utils
  • Viajes
  • Virtualization
  • Warhammer
  • YAML

Tags

anthill (1) apt (5) cellular-automatons (1) ceph (2) context (1) conways-life (1) cortador (1) debian (3) docker (9) docker-compose.yml (4) docker-swarm (5) DRY (1) El Imperio (2) Enanos (2) escenografía (3) fotos (3) GlusterFS (1) Guerreros del Caos (2) informática (1) Linux (8) M.2 (1) Mac (1) Madrid (2) maqueta (2) MariaDB (2) miniaturas (4) MySQL (2) NFS (2) NVMe (1) partida (2) poliestireno (1) portainer (1) proxmox (2) rocas (1) Sony A65 (2) SSH (5) ssh-key (1) Ubuntu (8) update (2) volume (1) Warhammer (11) Windows (3) WSL (2) WSL2 (2) YAML (1)

Archives

  • June 2024
  • May 2024
  • April 2024
  • February 2024
  • January 2024
  • September 2023
  • August 2023
  • June 2023
  • December 2021
  • April 2021
  • May 2020
  • April 2020
  • March 2020
  • November 2019
  • July 2018
  • February 2017
  • June 2015
  • April 2014
  • April 2011
  • January 2011
  • July 2010
  • June 2010
  • March 2010
  • November 2009
  • June 2009
  • December 2008
  • November 2008
  • October 2008
  • June 2008
  • May 2008
  • October 2007

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Copyright © 2025 OCIO y TECnología - Powered by Nevothemes.
Offcanvas