I am new to Docker and find that there are numerous images that are getting created (as seen in sudo docker images
) and found somewhere in stackoverflow to periodically run sudo docker rmi $(sudo docker images -q)
to remove all images. Why so many images get created? is there something wrong in my configuration?
docker-compose.yml
nginx:
build: ./nginx
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /etc/letsencrypt/:/etc/letsencrypt/
links:
- node:node
node:
build: ./node
restart: always
ports:
- "8080:8080"
volumes:
- ./node:/usr/src/app
- /usr/src/app/node_modules
The nginx dockerfile is
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
The nodejs dockerfile is
FROM node:9.3.0-alpine
WORKDIR /usr/src/app
COPY package*.json /usr/src/app/
RUN npm install --only=production
COPY . /usr/src/app
EXPOSE 8080
CMD [ "npm", "start" ]
The website/app works fine. Except that periodically, I am removing all containers, images and then run: sudo docker-compose up --build -d
.