Docker Issues
Port 5000 already in use
Port 5000 already in use
Error Message:Cause:
Another process is already using port 5000, which is required by the application (
docker-compose.yml:6 and server/index.js:11).Solutions:-
Find and stop the process using port 5000:
-
Stop conflicting Docker container:
-
Use a different port temporarily:
Edit
docker-compose.ymlto map to a different host port:
Docker build failures
Docker build failures
Error Message:Cause:
Network issues, corrupted cache, or missing dependencies during the multi-stage build process (
Dockerfile:4-14).Solutions:-
Clear Docker build cache:
-
Check internet connectivity:
-
Verify package.json files exist:
-
Check Docker daemon status:
-
Increase Docker resources:
- Go to Docker Desktop > Settings > Resources
- Increase Memory to at least 4GB
- Increase Disk space if needed
Container won't start or exits immediately
Container won't start or exits immediately
Error Message:Cause:
The container starts but exits due to application errors or missing files.Solutions:
-
Check container logs for errors:
-
Verify the built frontend exists:
This should show the built React files copied in
Dockerfile:43. -
Check if Node.js can start the server:
Expected output:
✅ Server running on port 5000 -
Verify the Dockerfile CMD is correct:
The
Dockerfile:49should have: -
Run container in interactive mode for debugging:
Docker image build is very slow
Docker image build is very slow
Cause:
Multi-stage builds and npm installs can be slow, especially when rebuilding frequently.Solutions:
-
Use Docker layer caching effectively:
The Dockerfile already copies
package*.jsonbefore source code (Dockerfile:9, 25), which helps cache npm install layers. -
Check .dockerignore file:
Create/verify
.dockerignoreto exclude unnecessary files: -
Use BuildKit for faster builds:
-
Build only when needed:
Use docker-compose to avoid rebuilding unnecessarily:
Cannot connect to Docker daemon
Cannot connect to Docker daemon
Error Message:Cause:
Docker daemon is not running or user lacks permissions.Solutions:
-
Start Docker daemon:
-
Add user to docker group (Linux):
-
Verify Docker is running:
Jenkins Pipeline Issues
Jenkins pipeline fails at Build Docker Image stage
Jenkins pipeline fails at Build Docker Image stage
Error in Jenkins Console:Cause:
Jenkins user doesn’t have permission to access Docker.Solutions:
-
Add Jenkins user to docker group:
-
Verify Docker socket permissions:
-
Check Jenkinsfile build command:
Verify
Jenkinsfile:14has:
Pipeline fails at Run Container stage
Pipeline fails at Run Container stage
Error in Jenkins Console:Cause:
Old container wasn’t properly stopped/removed.Solutions:
-
Verify cleanup command in Jenkinsfile:
The
Jenkinsfile:23should properly stop and remove old containers: -
Manually clean up containers:
-
Force remove if container is stuck:
Note that the Jenkinsfile uses container name
react-express-app, while docker-compose uses miniproject. Make sure you’re working with the correct container.Git checkout fails in Jenkins
Git checkout fails in Jenkins
Error in Jenkins Console:Cause:
Git credentials not configured or network issues.Solutions:
-
Verify repository URL in Jenkinsfile:
Check
Jenkinsfile:7: -
Test Git connectivity from Jenkins server:
-
Configure Git credentials in Jenkins:
- Go to Jenkins > Credentials
- Add GitHub credentials
- Update Jenkinsfile to use credentials
- Check network/firewall settings: Ensure Jenkins server can access GitHub.
Jenkins build succeeds but application not accessible
Jenkins build succeeds but application not accessible
Symptom:
Pipeline shows success, but
curl http://localhost:5000 fails.Cause:
Container started but application failed, or port mapping incorrect.Solutions:-
Check container status:
-
View container logs:
Should show:
✅ Server running on port 5000 -
Verify port mapping:
Check
Jenkinsfile:25: -
Test from within container:
-
Check if port is listening:
Application Issues
Node modules issues
Node modules issues
Error Message:Cause:
Dependencies not installed during build or incorrect COPY commands in Dockerfile.Solutions:
-
Verify dependencies are installed in Dockerfile:
Check
Dockerfile:10andDockerfile:26: -
Verify server dependencies:
Check
server/package.jsonincludes: -
Rebuild without cache:
-
Check COPY commands in production stage:
Verify
Dockerfile:40copies server with node_modules:
CORS errors in browser
CORS errors in browser
Error in Browser Console:Cause:
CORS middleware not configured properly.Solutions:
-
Verify CORS is enabled:
Check
server/index.js:2,5: -
Check cors dependency is installed:
Verify
server/package.jsonincludescors: ^2.8.5 -
Rebuild and restart container:
-
Configure specific CORS origins if needed:
Frontend not loading (404 errors)
Frontend not loading (404 errors)
Symptom:
Backend works, but React frontend returns 404.Cause:
Frontend build not copied correctly or Express not serving static files.Solutions:
-
Verify frontend build was copied:
Check
Dockerfile:43: -
Check build exists in container:
-
Add static file serving to Express:
Update
server/index.jsto serve the React build: -
Verify React build completed successfully:
Check build logs for errors in
Dockerfile:14stage.
Environment variables not working
Environment variables not working
Symptom:
Application can’t read environment variables.Cause:
Environment variables not passed to container.Solutions:
-
Add environment variables to docker-compose.yml:
-
Or use .env file:
-
Pass via docker run:
-
Verify in server/index.js:
The app uses
process.env.PORT || 5000(server/index.js:11)
Getting Help
For issues not covered here, check the container logs first:Most issues will have error messages in the logs that point to the root cause.