Docker:通过Dockerfile安装npm包时出错
这是我的Dockerfile的样子。 正如你所看到的,我正在尝试安装meteorJS,standardJS和一些npm软件包。
FROM ubuntu:latest # build arguments ARG APP_PACKAGES ARG APP_LOCALE=en_US ARG APP_CHARSET=UTF-8 ARG APP_USER=app ARG APP_USER_DIR=/home/${APP_USER} # add packages for building NPM modules (required by Meteor) RUN apt-get update -y RUN apt-get -y dist-upgrade RUN apt-get install -yqq \ python \ build-essential \ apt-transport-https \ ca-certificates \ curl \ locales \ nodejs \ npm \ nodejs-legacy \ sudo \ git RUN apt-get autoremove RUN apt-get clean RUN rm -rf /var/lib/apt/lists/* # set the locale (required by Meteor) RUN locale-gen ${APP_LOCALE} RUN localedef ${APP_LOCALE}.${APP_CHARSET} -i ${APP_LOCALE} -f ${APP_CHARSET} # create a non-root user that can write to /usr/local (required by Meteor) RUN useradd -mUd ${APP_USER_DIR} ${APP_USER} RUN chown -Rh ${APP_USER} /usr/local USER ${APP_USER} # MeteorJS RUN curl https://install.meteor.com/ | sh # StandardJS RUN npm install -g standard # NPM packages RUN npm install gridfs-stream gm fluent-ffmpeg
但最后一行似乎有一些问题,因为我不能安装npm包。
npm WARN enoent ENOENT: no such file or directory, open '/package.json' npm WARN !invalid#1 No description npm WARN !invalid#1 No repository field. npm WARN !invalid#1 No README data npm WARN !invalid#1 No license field. npm ERR! Linux 4.4.0-31-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "gridfs-stream" "gm" "fluent-ffmpeg" npm ERR! node v4.2.6 npm ERR! npm v3.5.2 npm ERR! path / npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access
在开始的时候,我设置了一个非root用户,为了让meteor运行起来,必须完成这个工作。 但是,这确实使最后一行的问题…
npm ERR! Error: EACCES: permission denied, access '/' npm ERR! at Error (native) npm ERR! { [Error: EACCES: permission denied, access '/'] errno: -13, code: 'EACCES', syscall: 'access', path: '/' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! Linux 4.4.0-31-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "gridfs-stream" "gm" "fluent-ffmpeg" npm ERR! node v4.2.6 npm ERR! npm v3.5.2 npm ERR! path npm-debug.log.4105014794 npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall open npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.4105014794' npm ERR! at Error (native) npm ERR! { [Error: EACCES: permission denied, open 'npm-debug.log.4105014794'] npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'open', npm ERR! path: 'npm-debug.log.4105014794' } npm ERR! npm ERR! Please try running this command again as root/Administrator.
答案在那里:
Error: EACCES: permission denied, access '/']
软件包正在安装在'/'
USER ${APP_USER}
在这里和下面的命令之间,我将把当前的工作目录更改为我希望安装的目录。
# MeteorJS RUN curl https://install.meteor.com/ | sh # StandardJS RUN npm install -g standard # NPM packages RUN npm install gridfs-stream gm fluent-ffmpeg
- 自动Dockerfile生成器
- 如何将docker工具箱,dockerfile,docker-compose文件绑定到可执行文件中?
- 弹簧系统参数被忽略
- 当我使用build命令时,Docker组合会忽略我的Dockerfile
- exec();(docker java api version 0.10.4)无法反序列化int的实例超出VALUE_FALSE标记,而readngdocker信息client.infoCmd()
- 即使在运行新的容器映像之后仍然使用相同的容量
- Gitlab docker和external_url
- 访问自定义networking中的泊坞窗容器的IP地址
- Shell脚本使用grep清理指定的docker容器