关于Docker使用的一些问题
- 构建docker镜像
docker build -t wechat-chatgpt:wechat-chatgp .
- Dockerfile文件,以此文件为例:
FROM node:19 AS app
# We don't need the standalone Chromium
RUN echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& apt-get update && apt-get -y install google-chrome-stable chromium xvfb\
&& rm -rf /var/lib/apt/lists/* \
&& echo "Chrome: " && google-chrome --version
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
ENV WECHATY_PUPPET_WECHAT_ENDPOINT=/usr/bin/google-chrome
CMD xvfb-run --server-args="-screen 0 1024x768x24" npm run dev
- 可能出现Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).问题(软件包公钥问题)
- 添加软件包密钥,Dockerfile改为:
FROM node:19 AS app
# We don't need the standalone Chromium
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B \
&& echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update && apt-get -y install google-chrome-stable chromium xvfb\
&& rm -rf /var/lib/apt/lists/* \
&& echo "Chrome: " && google-chrome --version
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
ENV WECHATY_PUPPET_WECHAT_ENDPOINT=/usr/bin/google-chrome
CMD xvfb-run --server-args="-screen 0 1024x768x24" npm run dev
- 如果要删除容器的环境变量,重新构建镜像会很耗时,以删除环境变量WECHATY_PUPPET_WECHAT_ENDPOINT为例,可以在运行容器时通过不赋值环境变量的方式删除:
docker run --name wechat-chatgpt -e WECHATY_PUPPET_WECHAT_ENDPOINT holegots/wechat-chatgpt:latest
- 通过docker inspect wechat-chatgpt查看修改结果,我尝试过在docker exec -it wechat-chatgpt bash中unset环境变量,但是没有成功
- 出现When using COPY with more than one source file, the destination must be a directory and end with a / 错误
COPY package*.json . # (fails!)
COPY package*.json ./ # (works:)
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
最上级!
喜欢就支持一下吧