I’m encountering a problem with a web application running in a Docker container on Windows. Although the application starts correctly and is accessible in the browser, I am unable to log in even though the credentials are correct. ( I am junior )
Details:
App – Nextjs 13.4.8
Docker Desktop 4.33.1
node v20.10.0
Docker Image:
I am using the node:18-alpine image to run a Next.js application. Here is my Dockerfile:
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN
if [ -f yarn.lock ]; then yarn --frozen-lockfile;
elif [ -f package-lock.json ]; then npm ci;
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile;
else echo "Lockfile not found." && exit 1;
fi
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN
if [ -f yarn.lock ]; then yarn run build;
elif [ -f package-lock.json ]; then npm run build;
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build;
else echo "Lockfile not found." && exit 1;
fi
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
RUN mkdir .next
RUN chown nextjs:nodejs .next
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
CMD HOSTNAME="0.0.0.0" node server.js
Issues:
The application starts correctly and listens on port 3000.
The application is accessible in the browser, but I cannot log in despite using the correct credentials.
I have checked environment variables and ensured that NEXT_PUBLIC_API_URL is correctly set in the .env.local file.
Container Logs:
The container logs indicate that the application is running correctly, but there are errors related to missing image resources that might be non-critical:
2024-07-31 19:21:43 The requested resource isn't a valid image for /images/logo.png received text/html; charset=utf-8
What I’ve Tried:
Checked .env.local configuration and file paths.
Verified that the application is accessible in the browser and listening on port 3000.
Question:
What could be causing the login issues with the application in a Docker container on Windows despite using the correct credentials? Are there additional diagnostic steps I can take to resolve this problem?