question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hang inside Docker container

See original GitHub issue

I have a docker-compose.yml file that runs integration tests, which includes talking to Pub/Sub. It looks like this:

version: "3.4"
services:
  app:
    image: node:10-alpine
    volumes:
    - ./:/app:ro
    working_dir: /app
    environment:
      - GOOGLE_APPLICATION_CREDENTIALS=/app/service_account.json
    entrypoint:
      - npm
      - run
      - test-e2e-debug

The tests hang when the call to publish() takes place. The relevant code:

exports = module.exports = async (data) => {
  const dataBuffer = Buffer.from(JSON.stringify(data));

  const topic = pubsub.topic(topicName, {
    batching: {
     maxMessages: 1, // max messages per batch
     maxMilliseconds: 50, // max wait time (ms) per batc
    },
  });

  const { publisher } = topic;
  const messageId = await publisher.publish(dataBuffer);
  log.error({ messageId }, 'pubsub complete');

  return messageId;
};

Running the same function outside the container, directly on my machine, works without issue. I’m using service account JSON creds with GOOGLE_APPLICATION_CREDENTIALS set in my environment, both in the container and outside.

Incidentally, when I configured GOOGLE_APPLICATION_CREDENTIALS to a nonexistent filename, it did cause an error to be thrown, so I assume the correct filename I’ve now set is being picked up correctly.

I’ve done a little debugging inside the pubsub client and can confirm that publish_() is called, but then it simply hangs. Running it in the debugger with ‘pause on caught exceptions’ causes no break. The request callback in publish_() never gets fired.

So my issue is two-fold:

  1. why the hang inside my container, rather than chucking out an error somewhere? (is there a retry-backoff loop going on?)
  2. how do I correctly configure authentication when running inside a container, given service account JSON credentials?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremyPleasecommented, Sep 4, 2019

Thanks for checking in. It looks like this was resolved in some version after v0.30.0. It now properly throws an Unable to detect a Project Id in the current environment.error instead of locking. This issue can be closed now.

0reactions
callmehiphopcommented, Sep 4, 2019

Awesome, thanks for the update @JeremyPlease!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Any commands hang inside docker container
Any commands hang terminal inside docker container. I login in container with docker exec -t php-zts /bin/bash And then print any elementary ...
Read more >
How to Install, Run and Delete Applications Inside Docker ...
While the command is running, detach from the container using Ctrl-p + Ctrl-q keys and the container will continue running even if the...
Read more >
docker hang with container in created status · Issue #38064
Steps to reproduce the issue:​​ Simple reproducer that I came with: docker run --name test --rm -it alpine sh. hit Ctrl-C fast enough...
Read more >
Debugging programs running inside Docker containers, in ...
An opinionated recipe for debugging programs running inside Docker containers, in production · Step 1: Build and publish 2 Docker images · Step...
Read more >
How to Fix and Debug Docker Containers Like a Superhero
Container errors are tricky to diagnose, but some investigative magic works wonders. Read along to learn how to debug Docker containers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found