Dockerfile和问题制作工作凉亭安装

kit*_*lku 5 docker bower-install dockerfile

我试图在节点上执行bower安装:4.1.2来自dockerfile的docker 容器.

我的dockerfile的一部分是这样的:

#Install bower to command line
RUN npm install -g bower

# Define the host folder that will contain the code
WORKDIR /application

# Copy src to application host folder**
ADD . /application

# RUN move to /application/public/webapp where there is a bower.json file and install it**
RUN cd public/webapp && bower install --allow-root --config.interactive=false

ENTRYPOINT ["npm"]
CMD ["start"]
Run Code Online (Sandbox Code Playgroud)

建立它并且建立它.

尽管显示以下内容,但此dockerfile不会构建bower_components文件夹:

Step 9 : RUN cd public/webapp && bower install --allow-root --config.interactive=false
 ---> Running in 937ad6c21887
/application/public/admintool
bower angular#1.4.7         not-cached git://github.com/angular/bower-angular.git#1.4.7
bower angular#1.4.7            resolve git://github.com/angular/bower-angular.git#1.4.7
bower angular#1.4.7           download https://github.com/angular/bower-angular/archive/v1.4.7.tar.gz
bower angular#1.4.7            extract archive.tar.gz
bower angular#1.4.7           resolved git://github.com/angular/bower-angular.git#1.4.7
bower angular#1.4.7            install angular#1.4.7

angular#1.4.7 bower_components/angular
Run Code Online (Sandbox Code Playgroud)

如果我进入容器,凉亭被识别为命令(它安装它).如果Im在容器内,则从/ application/public/webapp运行bower安装.从dockerfile它只是没有做任何事情.它都不抱怨.

有谁知道为什么?

小智 1

您是否可能通过 docker-compose.yml 文件或 docker run 命令中的 -v 参数将主机中的卷安装到容器中?

我问这个问题是因为您提到您的计算机上没有安装 Bower,因此您的代码库的主机副本中可能没有 Bower_components 文件夹。如果您随后运行容器并将包含主机上源代码的卷安装到容器中,则 Bower_components 文件夹将会丢失,这解释了为什么它似乎从容器中消失了。

我首先会通过不从主机安装任何卷来测试这是否确实是问题,并查看在构建并运行容器后是否仍然存在 Bower_components 文件夹。然后,您可以在主机上安装 Bower 并运行 Bower install,这样安装的卷就不会在开发过程中引起问题。