cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3317
Views
0
Helpful
7
Replies

User defined Environment variables for docker style apps

arun1587
Level 1
Level 1

Hello, 

Can we have a user-defined env variables other than the default CAF_XXX related variables in docker style apps? 

 

for example: 

in the Dockerfile, I could define

 

...
FROM apline:3.5 ENV TEST_VAR=xyz ...

and use it inside the application using

os.getenv("TEST_VAR")

?

 

 

thanks,

 

1 Accepted Solution

Accepted Solutions

Which version of ioxclient are you using ? This needs 1.7+ version of ioxclient utility. 

 

Here are the steps to get this feature support by rebuilding iox package

- get rid of any package.yaml in build directory

- use ioxclient 1.7+ to recreate iox package from a docker image. (ioxclient docker package <dockerimage> $PWD )

- Extract package.tar and check contents of package.yaml to confirm if the ENV variables mentioned in Dockerfile are populated correctly.

- If the above validation is succeeded then the generated IOx package (package.tar) should eventually populate those ENV variables in IOx app container as well.

 

 

 

View solution in original post

7 Replies 7

suressan
Cisco Employee
Cisco Employee

Hi,

 

IOx already have this capability to specify ENV variables via Dockerfile. Could you please confirm you can use it in your target process that way ? When you get inside app container, you can look at the env variables that are provisioned to the target process 

$/data/.env  

Note: Don't hard code /data directory in your target process, always use env variables provisioned to the target process. Refer this link for default set of env variables given to app - https://developer.cisco.com/docs/iox/#!application-development-concepts

Thanks

 

hi, 

yes, I'm able to access the predefined CAF related variables such as CAF_APP_APPDATA_DIR inside the dockerized application.  I would like to know if it is possible to define a new variable, example: TEST_VAR in the dockerfile and later to be used in the application once deployed in the router. I don't see `TEST_VAR` in `/data/.env`  file.

 

 

thanks,

 

 

Which platform are you trying it in ? What is the IOx version ?

 

In IR829 with latest IOx version (1.8), I do see the custom user env variable present in /data/.env.

 

iox-ir829-19-GOS-1:/# cat /data/.env
...
export CAF_SS_PORT=9443
export iox=test
export CAF_APP_CORE_DIR=/tmp/cores
export CAF_APP_ID=userenv
export CAF_SYSTEM_UUID=0c8d931d-c7cc-4fab-8b74-1f738621eb64iox-ir829-19-GOS-1:/#


iox-ir829-19-GOS-1:/#

Cisco829#show platform guest-os 
Guest OS status:
Installation: Cisco-GOS,version-1.6.3.1
State: RUNNING

ah, I use 1.6.3.1 on IR829 router.  looks like this is not supported in 1.6.3.1 version, can you please confirm it?

 

 

thanks for the support.

Which version of ioxclient are you using ? This needs 1.7+ version of ioxclient utility. 

 

Here are the steps to get this feature support by rebuilding iox package

- get rid of any package.yaml in build directory

- use ioxclient 1.7+ to recreate iox package from a docker image. (ioxclient docker package <dockerimage> $PWD )

- Extract package.tar and check contents of package.yaml to confirm if the ENV variables mentioned in Dockerfile are populated correctly.

- If the above validation is succeeded then the generated IOx package (package.tar) should eventually populate those ENV variables in IOx app container as well.

 

 

 

Nice, it worked!. Thanks much.

I was using quite an old version of iox-client 1.3.X. After I used version 1.8.1.0 I could see the env variable in package.yaml and as well as in the app once deployed in the router. 

So, in the end, we can conclude that we don't need the latest version of guest-os, right?. I'm currently running 1.6.3. or do you recommend to upgrade to latest ?.

 

thanks,

Nice, it worked!. Thanks much.

I was using quite an old version of iox-client 1.3.X. After I used version 1.8.1.0 I could see the env variable in package.yaml and as well as in the app once deployed in the router. 

So, in the end, we can conclude that we don't need the latest version of guest-os, right?. I'm currently running 1.6.3. or do you recommend to upgrade to latest ?.



thanks,
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: