Environment Variable Persisting

Function Description

In a system container, you can make the env variable persistent to the configuration file in the rootfs directory of the container by specifying the –env-target-file interface parameter.

Parameter Description

Command

Parameter

Value Description

isula create/run

--env-target-file

  • Variable of the string type.
  • The env persistent file must be in the rootfs directory and must be an absolute path.

Constraints

  • If the target file specified by –env-target-file exists, the size cannot exceed 10 MB.
  • The parameter specified by –env-target-file must be an absolute path in the rootfs directory.
  • If the value of –env conflicts with that of env in the target file, the value of –env prevails.

Example

Start a system container and specify the env environment variable and –env-target-file parameter.

[root@localhost ~]# isula run -tid -e abc=123 --env-target-file /etc/environment --system-container --external-rootfs /root/myrootfs none init
b75df997a64da74518deb9a01d345e8df13eca6bcc36d6fe40c3e90ea1ee088e
[root@localhost ~]# isula exec b7 cat /etc/environment
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TERM=xterm
abc=123

The preceding information indicates that the env variable (abc=123) of the container has been made persistent to the /etc/environment configuration file.

Rating

search results about are found