<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Access the environment variable from the custom container base cluster in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12400#M642</link>
    <description>&lt;P&gt;I suppose in the dockerfile of your image.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Jan 2023 10:26:45 GMT</pubDate>
    <dc:creator>-werners-</dc:creator>
    <dc:date>2023-01-12T10:26:45Z</dc:date>
    <item>
      <title>Access the environment variable from the custom container base cluster</title>
      <link>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12399#M641</link>
      <description>&lt;P&gt;Hi Databricks Community, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to set environment variables for all clusters in my workspace. The goal is to the have environment variable, available in all notebooks executed on the cluster.&lt;/P&gt;&lt;P&gt;The environment variable is generated in global init script and stored in the `/etc/environment` like documented here: &lt;A href="https://community.databricks.com/s/question/0D58Y000096UKm5SAG/set-environment-variables-in-global-init-scripts" alt="https://community.databricks.com/s/question/0D58Y000096UKm5SAG/set-environment-variables-in-global-init-scripts" target="_blank"&gt;https://community.databricks.com/s/question/0D58Y000096UKm5SAG/set-environment-variables-in-global-init-scripts&lt;/A&gt;&lt;/P&gt;&lt;P&gt;After my init script execution the `/etc/environment` content looks like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CLUSTER_DB_HOME=/databricks
DATABRICKS_RUNTIME_VERSION=10.4
DB_HOME=/databricks
DEFAULT_DATABRICKS_ROOT_VIRTUALENV_ENV=/databricks/python3
MLFLOW_CONDA_HOME=/databricks/conda
MLFLOW_PYTHON_EXECUTABLE=/databricks/python/bin/python
MLFLOW_TRACKING_URI=databricks
PYARROW_IGNORE_TIMEZONE=1
export MY_TEST_VAR=test&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The integration is working for the standard clusters and I can use the variable in the notebooks. &lt;/P&gt;&lt;P&gt;BUT for the clusters with defined custom docker container, the environment variable is invisible. &lt;/P&gt;&lt;P&gt;With the custom docker container cluster, I mean the clusters with the option "Use your own Docker container" set. For that type of clusters I can't access the environment variable. E.g the result of the code&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import os
print(os.getenv('MY_TEST_VAR'))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;is empty (None). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas where do I need to store environment variables to have them available in all cluster types?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 10:15:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12399#M641</guid>
      <dc:creator>lukaszl</dc:creator>
      <dc:date>2023-01-12T10:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Access the environment variable from the custom container base cluster</title>
      <link>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12400#M642</link>
      <description>&lt;P&gt;I suppose in the dockerfile of your image.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 10:26:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12400#M642</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2023-01-12T10:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Access the environment variable from the custom container base cluster</title>
      <link>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12401#M643</link>
      <description>&lt;P&gt;Thank you for the quick answer!&lt;/P&gt;&lt;P&gt;Unfortunately, I'm going to store the dynamic access token value in that environment variable. The token need to be generated per cluster and will expire in 4 hours. So my environment variable value is known only on cluster setup. That is the reason why I used the init script. So the docker image creation will be to early.&lt;/P&gt;&lt;P&gt;Does Databricks have the environment variable storage which will be injected before each notebook run? That will be the perfect solution for me.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 11:15:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12401#M643</guid>
      <dc:creator>lukaszl</dc:creator>
      <dc:date>2023-01-13T11:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Access the environment variable from the custom container base cluster</title>
      <link>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12402#M644</link>
      <description>&lt;P&gt;there is spark conf which you can set on cluster creation or even in the notebook.&lt;/P&gt;&lt;P&gt;No idea how that would work in docker though.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 13:48:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12402#M644</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2023-01-13T13:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Access the environment variable from the custom container base cluster</title>
      <link>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12404#M646</link>
      <description>&lt;P&gt;Thank you @Werner Stinckens​&amp;nbsp;!&lt;/P&gt;&lt;P&gt;Based on your suggestion I found the Databricks internal file &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;/databricks/spark/conf/spark-env.sh&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; which is containing the environment variables visible in the notebook. Adding the new variable over this file solves my problem.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 09:19:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12404#M646</guid>
      <dc:creator>lukaszl</dc:creator>
      <dc:date>2023-01-16T09:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Access the environment variable from the custom container base cluster</title>
      <link>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12405#M647</link>
      <description>&lt;P&gt;Thanks @Lukasz Lu​&amp;nbsp;- that worked for me as well. When I used the following script:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;#!/bin/bash
echo MY_TEST_VAR=value1 | tee -a /etc/environment &amp;gt;&amp;gt; /databricks/spark/conf/spark-env.sh&lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;for non-docker clusters, MY_TEST_VAR shows up twice in  ` /databricks/spark/conf/spark-env.sh`&lt;/LI&gt;&lt;LI&gt;for docker clusters MY_TEST_VAR shows up once&lt;/LI&gt;&lt;LI&gt;in both cases `os.getenv("MY_TEST_VAR")` gives value1 as expected&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 20:41:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/12405#M647</guid>
      <dc:creator>grazie</dc:creator>
      <dc:date>2023-01-23T20:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Access the environment variable from the custom container base cluster</title>
      <link>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/117798#M4064</link>
      <description>&lt;P&gt;where I have to use this script ?&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 05:19:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/access-the-environment-variable-from-the-custom-container-base/m-p/117798#M4064</guid>
      <dc:creator>Sahil0007</dc:creator>
      <dc:date>2025-05-06T05:19:28Z</dc:date>
    </item>
  </channel>
</rss>

