How to get all Travis CI environment variables, excluding the default system ones?

I want to pass into docker run all the environment variables I’ve configured in the Travis web UI.

I’m able to run env > .env to save them to a file and then pass that into docker via --env-file .env.

  • Transmission WebUI 409 in Docker Container
  • Docker tool or feature to define per-project container aliases?
  • How do I pull Docker images from the Tutum private registry with Amazon ECS?
  • Docker-Compose Elkstack
  • What does `--rm` do when running a docker image with data volumes?
  • Accessing mounted volumes from apache indocker
  • Unfortunately, this also overrides system ones such as PATH that interfere with the container.

    I’m able to filter out PATH using env | grep -vE "^(PATH=)" > .env but I’m wondering whether there’s a way to get just the Travis ones?

    Here’s my .travis.yml:

    language: bash
    sudo: required
      - docker
      - env | grep -vE "^(PATH=)" > .env
      - docker build -t mycompany/myapp .
      - docker run -i --env-file .env mycompany/myapp nosetests
      - echo "SUCCESS!"

  • accessing a docker container's file system through terminal
  • Docker error: too many open files
  • Dockerizing multiple instanced of a node app with different arguments
  • Ubuntu14.04 vs Ubuntu12.04 docker images
  • Docker build command output unavailable
  • How to reach a linked service in docker-compose?
  • One Solution collect form web for “How to get all Travis CI environment variables, excluding the default system ones?”

    I don’t recommend passing all your environment vars, but if you whitelist them by prefixing them with something like, say, TRAVIS_ you could do something like:

    export TRAVIS_WUT=foo
    export TRAVIS_FOO=asdf
    docker run $(printenv | grep -E '^TRAVIS_' | sed 's/TRAVIS_/-e /g')
      # would run -> docker run -e FOO=asdf -e WUT=foo something
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.