'set' command work differently in terminal and in script in Docker

I have set some environment variables(available only at runtime not known while creating container) in a running docker container as I explained here

Now when I go inside the container and run ‘set’ command I can see the environment variables but ‘env’ command does not show the variables I set using script.

  • MYSQLI Connection refused when connecting to another docker container running MariaDB
  • nginx default_site doesn't appear to be working
  • Docker 1.13 stack deploy with global service malfunction (target replicas increase without limit)
  • docker registry with s3
  • Layered file systems and volume mounts
  • Dockerizing a gradle build on a Mac
  • Now I want to read the environment variables from the host machine using a script. My script is as below-

    #!/bin/bash
    
    set > envVariableList
    

    But after successful execution of the script inside container ‘envVariableList’ file does not contain the environment variables I set after starting the container. The confusion here is, output of ‘set’ command in bash shell contains the environment variables but ‘set’ command in script gives different output to ‘envVariableList’ file. why? FYI: The script is run as ‘root’ inside container.

    Can anyone please help me to read the custom environment variables set inside container from host machine?

  • Two docker container need volumes from each other
  • Docker | How can I remove all containers but a certain few
  • Templating config file with docker
  • docker: structure needs cleaning
  • Exposing Elastic Beanstalk environment variables to Laravel's artisan using Docker
  • Vagrant start docker container after halt
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.