title: Docker image dies after "Got an error reading communication packets"
body: <p>I am facing currently a very weird behaviour that i cannot understand. My setup is: a microservice, using node 10.18.1 and knex js v0.20.10, for accessing the DB which is a mysql 5.7 db</p>
  
  <p><strong>The error</strong>
  For local tests, i have a docker-compose file that creates all the images including my project. The problem that i have is that, everytime i try to fetch information from the DB, my project image is being killed. After looking at the logs i saw the following message from mysql:</p>
  
  <pre><code>mysql    | 2020-03-12T00:40:18.457996Z 2 [Note] Aborted connection 2 to db: &lt;DB_NAME&gt; user: 'root' host: '172.18.0.3' (Got an error reading communication packets)
  </code></pre>
  
  <p>I was able to narrow the issue to the following code parts:</p>
  
  <pre><code>async function getUser (condition) {
      console.log('&gt;&gt; here', condition)
  
      const users = await knexClient(TABLE_NAME).where(condition) //&lt;-- all good here
  
      const user = users[0]  //&lt;-- still nothing wrong
      console.log('&gt;', user) // &lt;-- i can see the user from the DB
      await sleep(10000)  // &lt;-- It can even wait for 10 s
      return users.pop()  // &lt;-- BOOM! 
      // return null // &lt;-- If i return null, there is no error!?!?!? wtf?
  }
  ```
  </code></pre>
  
  <p>Function call</p>
  
  <pre><code>async function getByEmail (email) {
        **const user = await getUser({ email })**
  
        if (user == null) {
          throw applicationErrors.notFoundError('User not found or is not activated')
        }
  
        return user
    }
  </code></pre>
  
  <p>Basically the problem i am facing is that everytime i try to return the found user in the DB i get the mysql error(Got an error reading communication packets). After this error occurs, my docker image stops because is exiting with status code 0. </p>
  
  <p><strong>Fun fact</strong></p>
  
  <p>When i run the same source code, with the same Knex configuration, pointing to the local mysql docker image, the error never occurs!</p>
  
  <p><strong>My docker file is the following:</strong></p>
  
  <pre><code>FROM node:10-alpine
  ADD . /app
  WORKDIR /app
  RUN npm i --only=prod
  
  RUN rm -rf ./config/local.json
  RUN rm -rf ./docker-compose.override.yml
  
  CMD ["npm", "start"]
  </code></pre>
  
  <p>And my docker-compose looks like this:</p>
  
  <pre><code>version: "3"
  
  services:
    app:
      build: .
      container_name: &lt;SERVICE_NAME&gt;
      ports:
        - "9000:9000"
      # expose:
      #   - 9000
      depends_on:
        - mysql
  
    mysql:
      image: mysql:5.7.13
      container_name: mysql
      command: --default-authentication-plugin=mysql_native_password
      restart: unless-stopped
      volumes:
        - mysql:/var/lib/mysql
        - "./infrastructure/docker/initdb.sql:/docker-entrypoint-initdb.d/init.sql"
      environment:
        - MYSQL_ROOT_PASSWORD=password
      ports:
        - "3306:3306"
      # expose:
      #   - 3306
  
  volumes:
    mysql:
  </code></pre>
  
  <p>Any help or suggestion, will be highly appreciated!</p>