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.

  • How do I run a node container on AWS ECS without exiting
  • When multiple networks in Docker compose ports aren't being mapped
  • How to check if a process is running inside docker container
  • How to make odoo read admin_passwd from file?
  • Why there is no init / initctl on the docker centos image
  • Ansible docker_container command failing with no output
  • 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 have default machine in Windows 10
  • ENV variable isn't added correctly to the container environment
  • Docker and UFS filesystem
  • Pods doesn't run on another node after its node down
  • docker daemon error running devicecreate createpool
  • Golang docker library image cannot find go tool in $PATH
  • 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.