cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure Databricks token inside Docker File?

User16790091296
Contributor II

I have a docker file where I want to

  1. Download the Databricks CLI
  2. Configure the CLI by adding a host and token
  3. And then running a python file that hits the Databricks token

I am able to install the CLI in the docker image, and I have a working python file that is able to submit the job to the Databricks API but Im unsure of how to configure my CLI within docker.

2 REPLIES 2

User16752239289
Valued Contributor
Valued Contributor

The Databricks cli credential can be configured by editing file ~/.databrickscfg .

The file content will be like below:

[DEFAULT]
host = [workspace url]
username = [email id]
password = [password]
 
[profile 1]
host = [workspace url]
token = {personal access token}

After the Databricks Cli installed succeed, you can append your credential and workspace url to the file ~/.databrickscfg. Then the cli is ready to use.

sachingawade
New Contributor II

Hi I was facing same issue and searching for the solution but didnt get it, and now after working on it i have the solution 🙂

if you want to access databricks models/download_artifacts using hostname and access token like how you do on databricks cli 

databricks configure --token --profile <profile name>
 
>Databricks Host (should begin with https://): <hostname>
>Token : <token>

if you have created profile name and pushed models and just want to access the model/artifacts in docker using this profile 

Add below code in the docker file.

RUN pip install databricks_cli
 
ARG HOST_URL
 
ARG TOKEN
 
RUN echo "[<profile name>]\nhost = ${HOST_URL}\ntoken = ${TOKEN}" >> ~/.databrickscfg

#this will created your .databrickscfg file with host and token after build the same way you do using databricks configure command

Add args HOST_URL and TOKEN in the docker build

e.g

your host name = https://adb-5443106279769864.19.azuredatabricks.net/

your access token = dapi********************63c1-2

sudo docker build -t test_tag --build-arg HOST_URL=<your host name> --build-arg TOKEN=<your access token> .

And now you can access your experiments using this profilename Databricks:<profile name> in the code.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.