Node npm test to seeded postgres, Docker network container seeing varying results

I am running an Angular Node npm test against a seeded postgres database. This works in one environment but not another.

I have exported the images to and moved them from one environment to the other, and the results indicate that there’s a difference with the environments and not the docker images. I also have everything checked into git, and have done clean builds of the images.

  • Docker retain ENV variables
  • Access NFS files from Docker
  • Can't connect to django server running inside docker container (Docker for mac)
  • Where to find geard deployment fixture/config documentation?
  • Change Java “SecureRandom” in Dockerfile
  • How to run Rails migrations and seeding in Amazon Elastic Beanstalk single container Docker environment
  • pg=$(docker run -d postgres-seeded)
    docker run -it –net=container:$pg nodeapp npm test

    Here’s the matrix of what I’ve seen works/ and not works

    machine                          | npm test result       
    mac os X - docker 1.10.3         | success
    webstorm local to docker to post-|
    gres-seeded - mac os X docker    | success
    amazon ami on AWS docker 1.9.1   | error below
    amazon ami on AWS docker 1.10.3  | error below
    ubuntu 14.04 on AWS docker 1.10.3| success on one instance, error below

    the error when it fails is not able to connect to postgres

      4) AccessPermissionsRoutes "before all" hook:
         Error: The genericPool is not initialized.
          at Pool_PG.Pool.acquire (/usr/src/app/node_modules/knex/lib/pool.js:57:14)
          at /usr/src/app/node_modules/knex/lib/client.js:33:10
          at tryCatcher (/usr/src/app/node_modules/knex/node_modules/bluebird/js/main/util.js:26:23)
          at Promise._resolveFromResolver (/usr/src/app/node_modules/knex/node_modules/bluebird/js/main/promise.js:480:31)
          at new Promise (/usr/src/app/node_modules/knex/node_modules/bluebird/js/main/promise.js:70:37)
          at Client_PG.Client.acquireConnection (/usr/src/app/node_modules/knex/lib/client.js:31:10)

  • Docker does not release port inside container when tomcat service is stopped
  • Selenium in Docker container, Can we take screen shot
  • Doctrine missing “WHERE” clause
  • Docker not hosting anything on the port it says it is, what's going on?
  • Connect to another container using Docker compose
  • Connect to mongoDB socket in Docker
  • 2 Solutions collect form web for “Node npm test to seeded postgres, Docker network container seeing varying results”

    I was able to solve this issue. It has something to do with Postgres being left in an unstable state after seeding. It doesn’t happen all the time, so not sure when it does or does not.

    so the solution is to use a NEW postgres image everytime, and seed the data with a volume container.

      seeded=$(docker run --name seeded_1-v /var/lib/postgresql/data -d busybox true)
      pg=$(docker run --volumes-from $seeded -d postgres)
      docker run -e DATABASE_URL=postgres://postgres@localhost:5432 --net=container:$pg seeding-image

    where seeding-image is your custom docker image that seeds a postgres database.

    Recreate and reseed the Postgres container and try again. Most likely that will fix the connection issue you see in the code.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.