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

User defined Environment variables for docker style apps

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
Highlighted
Cisco Employee

Re: User defined Environment variables for docker style apps

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
Highlighted
Cisco Employee

Re: User defined Environment variables for docker style apps

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

 

Highlighted
Beginner

Re: User defined Environment variables for docker style apps

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,

 

 

Highlighted
Cisco Employee

Re: User defined Environment variables for docker style apps

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:/#

Highlighted
Beginner

Re: User defined Environment variables for docker style apps

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.

Highlighted
Cisco Employee

Re: User defined Environment variables for docker style apps

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

Highlighted
Beginner

Re: User defined Environment variables for docker style apps

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,

Highlighted
Beginner

Re: User defined Environment variables for docker style apps

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,
CreatePlease to create content