如何对我的 Docker 容器内的所有内容进行核爆并开始一个新容器?
How to nuke everything inside my Docker containers and start a new?
(我显然还没有完全掌握Docker的概念,所以当我incorrectly/inaccurately使用术语时请指正我。)
我 运行存储空间不足 space,所以我 运行 docker system prune
稍微清理一下我的系统。然而,在那之后不久(也许是立即),我在我的容器中启动 Webpack 开发服务器后开始 运行 进入分段错误。在这一点上我的猜测是,这是由于必须重建某些 npm 包,但由于一些旧的人工制品仍然存在,它没有这样做?如果我 运行 容器外的 Webpack 开发服务器,我不会 运行 进入分段错误:
web_1 | [2] Project is running at http://0.0.0.0:8000/
web_1 | [2] webpack output is served from /
web_1 | [2] 404s will fallback to /index.html
web_1 | [2] Segmentation fault (core dumped)
web_1 | [2] error Command failed with exit code 139.
因此,我想知道 docker system prune
是否真的删除了与我之前 运行 的 Docker 图片相关的所有内容,或者我是否可以做一些额外的清理工作。
我的Docker文件如下,其中./stacks/frontend
是Webpack开发服务器所在的目录运行(通过yarn start
):
FROM node:6-alpine
LABEL Name="Flockademic dev environment" \
Version="0.0.0"
ENV NODE_ENV=development
WORKDIR /usr/src/app
# Needed for one of the npm dependencies (fibers, when compiling node-gyp):
RUN apk add --no-cache python make g++
COPY ["package.json", "yarn.lock", "package-lock.json*", "./"]
# Unfortunately it seems like Docker can't properly glob this at this time:
#
COPY ["stacks/frontend/package.json", "stacks/frontend/yarn.lock", "stacks/frontend/package-lock*.json", "./stacks/frontend/"]
COPY ["stacks/accounts/package.json", "stacks/accounts/yarn.lock", "stacks/accounts/package-lock*.json", "./stacks/accounts/"]
COPY ["stacks/periodicals/package.json", "stacks/periodicals/yarn.lock", "stacks/periodicals/package-lock*.json", "./stacks/periodicals/"]
RUN yarn install # Also runs `yarn install` in the subdirectories
EXPOSE 3000 8000
CMD yarn start
这是它在 docker-compose.yml
中的部分:
version: '2'
services:
web:
image: flockademic
build:
context: .
dockerfile: docker/web/Dockerfile
ports:
- 3000:3000
- 8000:8000
volumes:
- .:/usr/src/app/:rw
# Prevent locally installed node_modules from being mounted inside the container.
# Unfortunately, this does not appear to be possible for every stack without manually enumerating them:
- /usr/src/app/node_modules
- /usr/src/app/stacks/frontend/node_modules
- /usr/src/app/stacks/accounts/node_modules
- /usr/src/app/stacks/periodicals/node_modules
links:
- database
environment:
# Some environment variables I use
我对没有清楚地了解正在发生的事情感到有些沮丧:)任何关于如何完全重新启动的建议(以及我弄错了哪些概念)将不胜感激。
很明显 docker system prune
有 some additional options,用核武器摧毁一切的正确方法是 docker system prune --all --volumes
。对我来说,关键可能是 --volumes
,因为它们可能包含必须重建的缓存包。
段错误现在消失了\o/
(我显然还没有完全掌握Docker的概念,所以当我incorrectly/inaccurately使用术语时请指正我。)
我 运行存储空间不足 space,所以我 运行 docker system prune
稍微清理一下我的系统。然而,在那之后不久(也许是立即),我在我的容器中启动 Webpack 开发服务器后开始 运行 进入分段错误。在这一点上我的猜测是,这是由于必须重建某些 npm 包,但由于一些旧的人工制品仍然存在,它没有这样做?如果我 运行 容器外的 Webpack 开发服务器,我不会 运行 进入分段错误:
web_1 | [2] Project is running at http://0.0.0.0:8000/
web_1 | [2] webpack output is served from /
web_1 | [2] 404s will fallback to /index.html
web_1 | [2] Segmentation fault (core dumped)
web_1 | [2] error Command failed with exit code 139.
因此,我想知道 docker system prune
是否真的删除了与我之前 运行 的 Docker 图片相关的所有内容,或者我是否可以做一些额外的清理工作。
我的Docker文件如下,其中./stacks/frontend
是Webpack开发服务器所在的目录运行(通过yarn start
):
FROM node:6-alpine
LABEL Name="Flockademic dev environment" \
Version="0.0.0"
ENV NODE_ENV=development
WORKDIR /usr/src/app
# Needed for one of the npm dependencies (fibers, when compiling node-gyp):
RUN apk add --no-cache python make g++
COPY ["package.json", "yarn.lock", "package-lock.json*", "./"]
# Unfortunately it seems like Docker can't properly glob this at this time:
#
COPY ["stacks/frontend/package.json", "stacks/frontend/yarn.lock", "stacks/frontend/package-lock*.json", "./stacks/frontend/"]
COPY ["stacks/accounts/package.json", "stacks/accounts/yarn.lock", "stacks/accounts/package-lock*.json", "./stacks/accounts/"]
COPY ["stacks/periodicals/package.json", "stacks/periodicals/yarn.lock", "stacks/periodicals/package-lock*.json", "./stacks/periodicals/"]
RUN yarn install # Also runs `yarn install` in the subdirectories
EXPOSE 3000 8000
CMD yarn start
这是它在 docker-compose.yml
中的部分:
version: '2'
services:
web:
image: flockademic
build:
context: .
dockerfile: docker/web/Dockerfile
ports:
- 3000:3000
- 8000:8000
volumes:
- .:/usr/src/app/:rw
# Prevent locally installed node_modules from being mounted inside the container.
# Unfortunately, this does not appear to be possible for every stack without manually enumerating them:
- /usr/src/app/node_modules
- /usr/src/app/stacks/frontend/node_modules
- /usr/src/app/stacks/accounts/node_modules
- /usr/src/app/stacks/periodicals/node_modules
links:
- database
environment:
# Some environment variables I use
我对没有清楚地了解正在发生的事情感到有些沮丧:)任何关于如何完全重新启动的建议(以及我弄错了哪些概念)将不胜感激。
很明显 docker system prune
有 some additional options,用核武器摧毁一切的正确方法是 docker system prune --all --volumes
。对我来说,关键可能是 --volumes
,因为它们可能包含必须重建的缓存包。
段错误现在消失了\o/