Reputation: 129
I try to run a node.js container with docker. Unfortunately, the container always stop and i can't get any log to understand why. When i restart the container, it instantly stops and i can't connect into it through the terminal.
About my docker-compose.yml:
version: '2'
services:
node:
build: .
container_name: node.cs
restart: unless-stopped
ports:
- 3030:3000
volumes:
# app
- ./app:/app
About my Dockerfile:
FROM node:10.9.0-alpine
# Create app directory
RUN mkdir /app
WORKDIR /app
# Set environment to "development" by default
ENV NODE_ENV development
# make port available outside of the image
EXPOSE 3000
As i suspect a permission conflict, here is my local working folder content:
drwxrwxr-x 2 myuser myuser 4096 août 30 00:07 app
-rwxr-xr-x 1 myuser myuser 791 août 30 06:41 docker-compose.yml
-rw-rw-r-- 1 myuser myuser 412 août 30 06:40 Dockerfile
-rw-rw-r-- 1 myuser myuser 98 août 28 22:43 .dockerignore
Any help to understand what is wrong with my code is welcomed. Thank you in advanced. jB
Upvotes: 1
Views: 1615
Reputation: 1
Run the command:
docker compose run server npm install jest
And it will work. Or else, your container node might a little bit old version, then just:
docker image pull node
Upvotes: 0
Reputation: 3427
Dockerfile
FROM node:10.9.0-alpine
WORKDIR /app
ADD . /app
RUN npm install
RUN npm install -g nodemon
# Set environment to "development" by default
ENV NODE_ENV=development
# Create app directory
# make port available outside of the image
CMD ["nodemon", "-L"]
EXPOSE 3000
docker-compose.yml
version: '3'
services:
application:
build: .
container_name: whatever_name_you_choice
restart: always
ports:
- "3000:3000"
volumes:
- .:/app
Upvotes: 0