gpt4 book ai didi

docker - GCR-影像缺少两个文件,其余全部,本地影像已完成

转载 作者:行者123 更新时间:2023-12-02 19:48:02 27 4
gpt4 key购买 nike

我有一个要部署到Kubernetes(GKE)的容器,并且我在本地构建的镜像很好,并且可以按预期运行,但是当将run命令更改为pwd && ls时,该镜像似乎是从Google Container Registry中提取的返回此处显示的输出:

I 2020-06-17T16:24:54.222382706Z /app
I 2020-06-17T16:24:54.226108583Z lost+found
I 2020-06-17T16:24:54.226143620Z package-lock.json

在本地容器中使用 docker run -it <container:tag> bash运行时,相同命令的输出是这样的:
#${API_CONTAINER} resolves to gcr.io/<project>/container: I.E. tag gets appended

.../# docker run -it ${API_CONTAINER}latest bash
root@362737147de4:/app# pwd
/app
root@362737147de4:/app# ls
Dockerfile dist files node_modules package.json ssh.bat stop_forever.bat test tsconfig.json
cloudbuild.yaml environments log package-lock.json src startApi.sh swagger.json test.pdf tsconfig.test.json
root@362737147de4:/app#

我对此的想法始于要么要么推送注册表实际上是行不通的,要么是我没有提出正确的建议,即从先前由云构建构建的 latest标签中删除一些标签来实现此目的。

潜在的问题是什么?有什么可能解决此问题?

编辑:在部署中使用了不同的标签之后,在构建过程中使用了 --no-cache,并从另一台计算机上的注册表中提取了数据,我的想法是GKE在从GCR提取镜像时遇到了问题。有什么方法可以将其放置在其他位置,或者可以了解拉动的情况吗?

编辑2:

所以是的,我有一个可以共享的docker文件,但是请注意,我已经继承了它,并且不了解构建此文件的过程,或者为什么其他开发人员需要采取一些步骤。 (我绝对有兴趣尽可能地重构它。
FROM node:8.12.0

RUN mkdir /app
WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

RUN apt-get update && apt-get install snmp -y

RUN npm install --unsafe-perm=true
RUN apt-get update \
&& apt-get install -y \
gconf-service \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgcc1 \
libgconf-2-4 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
ca-certificates \
fonts-liberation \
libappindicator1 \
libnss3 \
lsb-release \
xdg-utils \
wget

COPY . /app


# Installing puppeteer and chromium for generating PDF of the invoices.


# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update \
&& apt-get install -y wget gnupg libpam-cracklib \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*


# Uncomment to skip the chromium download when installing puppeteer. If you do,
# you'll need to launch puppeteer with:
# browser.launch({executablePath: 'google-chrome-unstable'})
# ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

# Install puppeteer so it's available in the container.
RUN npm i puppeteer \
# Add user so we don't need --no-sandbox.
# same layer as npm install to keep re-chowned files from using up several hundred MBs more space
&& groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /app/node_modules

#build the api, and move into place.... framework options are limited with the build.
RUN npm i puppeteer kiwi-server-cli && kc build -e prod
RUN rm -Rf ./environments & rm -Rf ./src && cp -R ./dist/prod/* .


# Run everything after as non-privileged user.
# USER pptruser

CMD ["google-chrome-unstable"] # I have tried adding this here as well "&&", "node", "src/server.js"

为了推送图像,我使用以下命令: docker push gcr.io/<projectid>/api:latest-<version>,我已经使用 cloud auth configure-docker设置了凭据,这是yaml list 的经过净化的版本:
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f ./docker-compose.yml
kompose.version: 1.21.0 ()
creationTimestamp: null
labels:
io.kompose.service: api
name: api
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: api
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert -f ./docker-compose.yml
kompose.version: 1.21.0 ()
creationTimestamp: null
labels:
io.kompose.service: api
spec:
containers:
- args:
- bash
- -c
- node src/server.js
env:
- name: NODE_ENV
value: production
- name: TZ
value: America/New_York
image: gcr.io/<projectId>/api:latest-0.0.9
imagePullPolicy: Always
name: api
ports:
- containerPort: 8087
resources: {}
volumeMounts:
- mountPath: /app
name: api-claim0
- mountPath: /files
name: api-claim1
restartPolicy: Always
serviceAccountName: ""
volumes:
- name: api-claim0
persistentVolumeClaim:
claimName: api-claim0
- name: api-claim1
persistentVolumeClaim:
claimName: api-claim1
status: {}

最佳答案

解决方案来自docker-compose.yml文件的原始意图,该文件是通过称为kompose的工具转换为kubernetes list 的。原始的docker-compose文件用于开发,因此具有适当的覆盖,可将本地开发环境推送到正在运行的容器中。

这是因为yml文件中的原因:

services:
api:
build: ./api
volumes:
- ./api:/app
- ./api/files:/files

在kubernetes list 上将其翻译为:
      volumeMounts:
- mountPath: /app
name: api-claim0
- mountPath: /files
name: api-claim1
volumes:
- name: api-claim0
persistentVolumeClaim:
claimName: api-claim0
- name: api-claim1
persistentVolumeClaim:
claimName: api-claim1

哪个Kubernetes没有文件可提供,并且该应用程序实质上被一个空卷覆盖,因此找不到该文件。

删除kubernetes list 中的指令可以成功。

提醒我们大家注意。

关于docker - GCR-影像缺少两个文件,其余全部,本地影像已完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62434471/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com