Dockerfile构建镜像,同时需要python和rust环境,求助 # 使用基础 Python 镜像 FROM python:3.11.0-slim # 更改apt源 RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list # 安装rust所需 RUN apt-get update && \ apt-get install -y --no-install-recommends \ curl \ build-essential \ libssl-dev && \ rm -rf /var/lib/apt/lists/* && \ apt-get clean # 安装 Rust,因为没有科学上网,这样设置之后,可以从国内下载rust-init # ** 或者有可能这里就有错,但是我看rust的相关东西都下载下来了 ** ENV RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup ENV RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # 设置 Rust 环境变量 ENV PATH="${CARGO_HOME}/bin:${PATH}" # 验证 Rust 安装** 这一步出错 ** RUN rustc --version && cargo --version # 后面大概就说add代码到根目录,然后pip升级,pip安装所需库 ADD . . WORKDIR ... RUN pip install --upgrade pip -i https://pypi.doubanio.com/simple/ RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple EXPOSE 8080 CMD ["python", "main.py"] "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250113/9cd6f9c1bd7803454c4a40f4cebc88c2.png) 这个项目是其他人做的,他在python里面使用了一个包名叫“ploygons”,这个包好像是处理图像时比pandas还是什么快很多,但是这个包需要rust环境 cargo ,才能正常运行,在开发环境里安装rust环境还是比较轻松的。 但是我现在需要测试放在docker环境运行,然后打包发送给别人。
puppeteer官方Docker镜像:"https://pptr.nodejs.cn/guides/docker" (https://link.segmentfault.com/?enc=AnfmLzTduR5bBUnSvVyycw%3D%3D.OYOLZxiap7E%2BO9UTvxFX6zj%2FKpPhh0fNsPPXtEDssN6BNANqYGHavfKiMSGH4H5x) 现在我的需求是使用"express"创建接口,当调用接口传递链接,再puppeteer访问链接进行截图,截图后把截图上传阿里Oss,返回上传阿里Oss后的图片链接 我的想法是再打包一次: "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250104/91ecdd52b97ba274db31f9af1d180daa.png) FROM ghcr.io/puppeteer/puppeteer 把官方镜像打包进行我们自己的Dockerfile,请大佬们这样可行吗?这个Dockerfile配置应该怎么写?请大佬指点下
生产环境是多个客户共用的SAAS类型, 应用环境是前端UI和两个java应用, 环境运行过程中需要连接本机或其他数据库, 请教一下如何使用DockerFile编排镜像, 思路或者想法皆可留言, 具体应该怎么编写Dockerfile? 拜谢!
安装到Ubuntu容器中需要运行/etc/init.d/amh-start才会启动, 把/etc/init.d/amh-start放到dockerfile中的cmd 运行容器启动完程序容器会自动关闭
我的Dockerfile配置: FROM ghcr.io/puppeteer/puppeteer:latest EXPOSE 4000 # 设置工作目录 WORKDIR /yice RUN chmod -R 777 /yice # # 复制源码 COPY ./dist /yice/dist COPY ./scripts /yice/scripts COPY ./.env /yice/ COPY ./package.json /yice COPY ./static /yice/static COPY ./tsconfig.json /yice/ COPY ./tsconfig.build.json /yice/ COPY ./node_modules /yice/node_modules CMD npm run start:prod 报错信息: "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250103/aa4df9d9d8f7e3ee94f62825f2191e56.png) 我已经尝试过以下几种方法: * Dockerfile配置中添加"RUN chmod -R 777 /yice" * Dockerfile配置添加 "USER root",它会报: "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250103/add04e0ca3e42672921842849a67a692.png) 找不Chrome,然后因为ghcr.io/puppeteer/puppeteer:latest镜像切换的用户名为"pptruser",所以我手动在代码里给puppeteer配置"executablePath: '/home/pptruser/node_modules/chrome' ",它又报找不到 "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250103/dc8b3c6e1d2edae81be0900d53ff74ed.png) * Dockerfile配置添加 "USER pptruser",它还是报: "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250103/aa4df9d9d8f7e3ee94f62825f2191e56.png) 请问有没有大佬指点下?感谢🙏了
nodejs使用thinkjs开发的项目docker-compose部署失败 我在用docker-compose部署一个node.js项目时遇见的无法部署,该项目之前使用pm2直接部署在宿主机是可以正常运行的,项目使用了thinkjs框架,下面的是我的docker-compose文件: services: node: image: node:18.17.1 volumes: - /data/jxxw/node/h5-api/:/data/jxxw/node working_dir: /data/jxxw/node command: npm start ports: - "8362:8362" h5-api是我把node项目解压之后的文件夹,执行docker-compose up -d之后发现容器未启动,查看logs获得如下提示: > jxxw-api@1.0.0 start > node production.js node:internal/modules/cjs/loader:1080 throw err; ^ Error: Cannot find module 'thinkjs' Require stack: - /data/jxxw/node/production.js at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15) at Module._load (node:internal/modules/cjs/loader:922:27) at Module.require (node:internal/modules/cjs/loader:1143:19) at require (node:internal/modules/cjs/helpers:121:18) at Object. (/data/jxxw/node/production.js:2:21) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) at Module._load (node:internal/modules/cjs/loader:960:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) { code: 'MODULE_NOT_FOUND', requireStack: [ '/data/jxxw/node/production.js' ] } Node.js v18.17.1 看提示是未读取到thinkjs的依赖,据node开发同学反馈他的打包流程如下: 1.npm install 2.npm pack 之后就把生成的tgz文件给到我这边, 我尝试过写dockerfile文件解决,如下: # 使用官方 Node.js 镜像 FROM node:18.17.1 # 设置工作目录 WORKDIR /data/jxxw/node # 将当前目录下的所有内容都复制到位于 /app 的容器中 COPY . /data/jxxw/node # 安装项目依赖 RUN npm install # 暴露端口,供外部访问 EXPOSE 8362 提示install失败: => ERROR [4/4] RUN npm install 1542.3s ------ > [4/4] RUN npm install: 1542.3 npm ERR! code ECONNREFUSED 1542.3 npm ERR! syscall connect 1542.3 npm ERR! errno ECONNREFUSED 1542.3 npm ERR! FetchError: request to https://registry.npmjs.org/ava failed, reason: connect ECONNREFUSED 104.16.28.34:443 1542.3 npm ERR! at ClientRequest. (/usr/local/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14) 1542.3 npm ERR! at ClientRequest.emit (node:events:514:28) 1542.3 npm ERR! at TLSSocket.socketErrorListener (node:_http_client:501:9) 1542.3 npm ERR! at TLSSocket.emit (node:events:526:35) 1542.3 npm ERR! at emitErrorNT (node:internal/streams/destroy:151:8) 1542.3 npm ERR! at emitErrorCloseNT (node:internal/streams/destroy:116:3) 1542.3 npm ERR! at process.processTicksAndRejections (node:internal/process/task_queues:82:21) 1542.3 npm ERR! FetchError: request to https://registry.npmjs.org/ava failed, reason: connect ECONNREFUSED 104.16.28.34:443 1542.3 npm ERR! at ClientRequest. (/usr/local/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14) 1542.3 npm ERR! at ClientRequest.emit (node:events:514:28) 1542.3 npm ERR! at TLSSocket.socketErrorListener (node:_http_client:501:9) 1542.3 npm ERR! at TLSSocket.emit (node:events:526:35) 1542.3 npm ERR! at emitErrorNT (node:internal/streams/destroy:151:8) 1542.3 npm ERR! at emitErrorCloseNT (node:internal/streams/destroy:116:3) 1542.3 npm ERR! at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { 1542.3 npm ERR! code: 'ECONNREFUSED', 1542.3 npm ERR! errno: 'ECONNREFUSED', 1542.3 npm ERR! syscall: 'connect', 1542.3 npm ERR! address: '104.16.28.34', 1542.3 npm ERR! port: 443, 1542.3 npm ERR! type: 'system', 1542.3 npm ERR! requiredBy: '.' 1542.3 npm ERR! } 1542.3 npm ERR! 1542.3 npm ERR! If you are behind a proxy, please make sure that the 1542.3 npm ERR! 'proxy' config is set properly. See: 'npm help config' 1542.3 1542.3 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-01-30T14_55_34_130Z-debug-0.log ------ Dockerfile:8 -------------------- 6 | COPY . /data/jxxw/node 7 | # 安装项目依赖 8 | >>> RUN npm install 9 | # 暴露 8000 端口,供外部访问 10 | EXPOSE 8362 -------------------- ERROR: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1 ERROR: Service 'node' failed to build : Build failed 文件夹里面的内容: "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20241012/51442a17882aca0ab26a493929096900.png) "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20241012/f8f4ac3f0bf1276f5a936c80d592112c.png) 麻烦大佬指点为何,个人理解是thinkjs没有被正确的install,如果我想只写docker-compose文件不写dockerfile文件应该如何操作
我执行docker info Registry Mirrors: https://ev9s0y223.mirror.aliyuncs.com/ https://docker.mirrors.ustc.edu.cn/ Live Restore Enabled: false WARNING: API is accessible on http://0.0.0.0:2375 without encryption. Access to the remote API is equivalent to root access on the host. Refer to the 'Docker daemon attack surface' section in the documentation for more information: https://docs.docker.com/go/attack-surface/ WARNING: No swap limit support WARNING: The devicemapper storage-driver is deprecated, and will be removed in a future release. Refer to the documentation for more information: https://docs.docker.com/go/storage-driver/ WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device. 已经可以看到镜像源了。 然后 sudo systemctl daemon-reload sudo systemctl restart docker 这两条也执行了。 但是,但是拉镜像的时候还是从docker.io拉, 请教各位大佬还有啥要处理的? { “registry-mirrors”:[“"https://ev9s0y223.mirror.aliyuncs.com/" (https://link.segmentfault.com/?enc=4NFtZ7Aoto6m9nk7WW5adQ%3D%3D.ngpY45acnbPKjg4Uox4ZjKTuRQ45zGTUg8G5zUbYL17ZWyaJX6bYEp%2BjQlZ0IMnl)”] } 上面这个已配置,也重启了 sudo systemctl daemon-reload sudo systemctl restart docker 就想用国内的镜像源加速,现在安装太耗时了,随便就是几个小时!
Linux 版本: ubuntu-22.04.4-desktop-amd64.iso 运行在 VMware Dockerfile: "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20241002/4d744d90d779c6ad2714964e50e65c49.png) 因无法访问"http://192.168.110.131:81/" (https://link.segmentfault.com/?enc=R%2FtuB4cCulgaLuzyXj3ISw%3D%3D.sHvqHbAAb%2FbWTh%2Bq4P2tkYYV5rx5PC%2FDk%2FnYWSJ8mNQ%3D), 所以我想看看日志,但情况却是 没有输出而且还卡在那里了: "image.png" (https://wmprod.oss-cn-shanghai.aliyuncs.com/c/user/20241002/01601b39541f85d9e35e818554773e2c.png) 问题1: 我的Dockerfile有问题吗? 问题2: 输出日志的异常可能是什么原因? (cat 命令是正常的别的文件可以输出) 如何修改呢?
redisConnectOptions const redisConnectOptions: RedisConnectOptions = { hostname: "redis://redis-stack", port: 6379, }; docker-compose.yml redis-stack: image: redis/redis-stack:latest container_name: redis-stack ports: - "6379:6379" - "6380:8001" networks: - my-network docker log 2024-05-19 18:53:04 error: Uncaught (in promise) Error: failed to lookup address information: Name or service not known 2024-05-19 18:53:04 : await Deno.connect(dialOpts); 2024-05-19 18:53:04 ^ 2024-05-19 18:53:04 at async Object.connect (ext:deno_net/01_net.js:587:55) 2024-05-19 18:53:04 at async RedisConnection.#connect (https://deno.land/x/redis@v0.32.0/connection.ts:190:11) 2024-05-19 18:53:04 at async RedisConnection.#connect (https://deno.land/x/redis@v0.32.0/connection.ts:222:7) 2024-05-19 18:53:04 at async RedisConnection.#connect (https://deno.land/x/redis@v0.32.0/connection.ts:222:7) 2024-05-19 18:53:04 at async RedisConnection.#connect (https://deno.land/x/redis@v0.32.0/connection.ts:222:7) 2024-05-19 18:53:04 at async RedisConnection.#connect (https://deno.land/x/redis@v0.32.0/connection.ts:222:7) 2024-05-19 18:53:04 at async RedisConnection.#connect (https://deno.land/x/redis@v0.32.0/connection.ts:222:7) 2024-05-19 18:53:04 at async RedisConnection.#connect (https://deno.land/x/redis@v0.32.0/connection.ts:222:7) 2024-05-19 18:53:04 at async RedisConnection.#connect (https://deno.land/x/redis@v0.32.0/connection.ts:222:7) 2024-05-19 18:53:04 at async RedisConnection.#connect (https://deno.land/x/redis@v0.32.0/connection.ts:222:7)
dockerfile 安装不上redis mongdb "image.png" (https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241030/bfc7f7ab1154357960a1b86496c37708.png) 我试过换镜像源但是还是一样的错误