DockerFile
FROM node:latest
WORKDIR /app
COPY . .
RUN npm install
EXPOSE 8080
ENTRYPOINT ["nodemon", "server.js"]
Server.js
const express = require('express');
const swaggerUi = require('swagger-ui-express');
const app = express();
const userRouter = require('./routes/userRoutes');
const productRouter = require('./routes/productsRoutes');
const swaggerFile = require('./swagger/swagger_output.json');
const PORT = 8000;
app.use('/doc', swaggerUi.serve, swaggerUi.setup(swaggerFile));
app.use(express.json());
app.listen(PORT, () => {
console.log(`Server rodando em: http://localhost:${PORT}`)
});
app.use('/api', userRouter);
app.use('/api/products', productRouter);
The error:
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "nodemon": executable file not found in $PATH: unknown.
The command
docker run -d -p 8000:8080 projeto-pratico-api/node
*projeto-pratico-api/node = name of the image
2
Answers
Your main container process is
nodemon
, but it’s not installed in your image. Since a Docker image contains an immutable copy of the application code, it will never change while the container is running, and you don’t need a monitoring tool likenodemon
; just set the main container process to runnode
.Try installing nodemon from your Dockerfile?
Add:
Full updated Dockerfile:
Second approach, use node instead of nodemon: