Hope this is a proper sub for asking this.

disclaimer : Consider me a programming novice, with HTML and limited PHP/CSS experience.

Ive been messing with docker compose, and i’m loving it. Ive also written a small script that i want to dockerize, but i want to use the environment list. What is a proper code for getting the ENV data in your script?

Ive been duckduckgo-ing (doesnt sound like the old days, does it) and i cant figure it out.

  • thomasloven@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    10 months ago

    Depends on the language the script is written in. If it’s bash/sh then it’s usually just $VARIABLE

    • cmhe@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      10 months ago

      Environment variables isn’t a concept of just docker, but general native app programming. So look into the docs of your language.

  • TrustingZebra@lemmy.one
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    10 months ago

    You need to learn how to write a Dockerfile (plenty of guides online). Not that a Dockerfile is different from a compose.yaml file (in development I use both).

    • That Dutch guyOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      10 months ago

      The whole docker thing is rather new to me, thanks for the hints.

      • TrustingZebra@lemmy.one
        link
        fedilink
        English
        arrow-up
        2
        ·
        10 months ago

        No problem! Let me know if you have questions. Docker was new to me a few years ago, now I work with it professionally.

  • webuge@lemmy.dbzer0.com
    cake
    link
    fedilink
    English
    arrow-up
    3
    ·
    10 months ago

    In my opinion you would want to create a Dockerfile to generate a Docker Image with your script and the ENVs in it. Remember though this script will run inside the docker container and the host will not see any modification. Could you explain in more details what this script would do?

    • That Dutch guyOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      10 months ago

      right now its a javascript countdown till christmas.

      Id like to pass the target year through a variable though.

  • conrad82@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    10 months ago

    Not a direct answer to your question, but I learned a bit by searching github for Dockerfile and docker-compose.yml