我是新手 Docker 用户,发现有大量的镜像在创建(可以通过
docker-compose.yml
网站/应用程序运行良好。除了定期删除所有容器、镜像,然后运行:
sudo docker images
命令查看),在 Stackoverflow 上找到一个解决方案:定期运行 sudo docker rmi $(sudo docker images -q)
命令以删除所有镜像。为什么会有这么多的镜像被创建?我的配置是否存在问题?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
nginx的Dockerfile如下:
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
Node.js的Dockerfile如下:
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" ]
网站/应用程序运行良好。除了定期删除所有容器、镜像,然后运行:
sudo docker-compose up --build -d
。