Winston logs does not work in the Docker Container

  docker, express, node.js, typescript, winston

I am creating a nodejs/express app with typescript. I have installed the winston package. using npm install winston.
I am following this article. i want to dockerize this.

What i have done so far:

  1. I have imported the winston package in the logger.ts.
  2. import the logger.js file to the server.ts file.

Winston logger works when I run npm run dev command. I see the winston logs in the console.
When i implement the same in docker container.

I use docker build -t docker-image . command then docker-compose up.

My Dockerfile:

FROM node:10
WORKDIR /app
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . /app

EXPOSE 5000
CMD [ "node", "dist/server.js" ]

docker-compose.yml file:

version: '3'
services:
  app:
    container_name: hoptik-pims-node
    restart: always
    build: .
    ports:
      - '5000:5000'
    links:
      - mongo
  mongo:
    container_name: mongo
    image: mongo
    ports:
      - '2717:27017'

I try to access the page http://localhost:5000/logger. I get Cannot GET /logger.

I do not understand what I am doing wrong. I have spent last couple of days trying fix this issue. Can someone help me fix this.

Thanks in advance.

Source: Docker Questions

LEAVE A COMMENT