docker - 运行 mkdir 文件夹,添加文件夹 / 。和 COPY 文件夹/ 。在 Dockerfile 中不起作用
问题描述
我一直在尝试在 docker 中构建服务 solr,编写了一个 Dockerfile 来构建图像,Dockerfile 中的内容如下。
FROM solr:8.6.3
LABEL maintainer="halloweens"
# create Core
USER root
WORKDIR /opt/solr-8.6.3/server/solr
# RUN mkdir ik_core // didn't work, so I annotated
ADD ik_core/ . // I was trying this way to add this directory into it, COPY as well, didn't work
WORKDIR ik_core
RUN echo 'name=ik_core' > core.properties
# RUN mkdir data // didn't work, so I annotated
# setup the ik-analyzer // this part quite succeeded
WORKDIR /opt/solr-8.6.3/server/solr-webapp/webapp/WEB-INF/lib
ADD ik-analyzer-8.3.0.jar .
ADD solr-core-8.6.3.jar .
ADD solr-dataimporthandler-8.6.3.jar .
ADD solr-dataimporthandler-extras-8.6.3.jar .
ADD solr-solrj-8.6.3.jar .
WORKDIR /opt/solr-8.6.3/server/solr-webapp/webapp/WEB-INF
ADD hotword.dic .
ADD stopword.dic .
ADD IKAnalyzer.cfg.xml .
# add conf
ADD managed-schema /opt/solr-8.6.3/server/solr/ik_core/conf // oop, it's like doesn't have the targer directory, so, didn't work
USER solr
WORKDIR /opt/solr-8.6.3
主要问题是它不能在其中新建文件夹,也不能将文件夹移动/复制到其中,这是构建此映像时的一些消息。
Building solr
Step 1/20 : FROM solr:8.6.3
---> 6cd44b0427c6
Step 2/20 : LABEL maintainer="halloweens"
---> Using cache
---> c00102273187
Step 3/20 : USER root
---> Using cache
---> bf673ba7db76
Step 4/20 : WORKDIR /opt/solr-8.6.3/server/solr
---> Using cache
---> 49944dc42904
Step 5/20 : ADD ik_core/ .
---> Using cache
---> a1242656d9b6
Step 6/20 : WORKDIR ik_core
---> Using cache
---> 3324f309b66d
Step 7/20 : RUN echo 'name=ik_core' > core.properties
---> Using cache
---> 93375111a380
Step 8/20 : WORKDIR /opt/solr-8.6.3/server/solr-webapp/webapp/WEB-INF/lib
---> Using cache
---> 090df62ab5f9
Step 9/20 : ADD ik-analyzer-8.3.0.jar .
---> Using cache
---> 151144e7e5b2
Step 10/20 : ADD solr-core-8.6.3.jar .
---> Using cache
---> 5b12febb071c
Step 11/20 : ADD solr-dataimporthandler-8.6.3.jar .
---> Using cache
---> d738b7026a4e
Step 12/20 : ADD solr-dataimporthandler-extras-8.6.3.jar .
---> Using cache
---> aa2d0a16524d
Step 13/20 : ADD solr-solrj-8.6.3.jar .
---> Using cache
---> 10562eab8c4b
Step 14/20 : WORKDIR /opt/solr-8.6.3/server/solr-webapp/webapp/WEB-INF
---> Using cache
---> ce0c98054b6e
Step 15/20 : ADD hotword.dic .
---> Using cache
---> de3ad2605a45
Step 16/20 : ADD stopword.dic .
---> Using cache
---> c25cc36a0513
Step 17/20 : ADD IKAnalyzer.cfg.xml .
---> Using cache
---> e1c19c123f2c
Step 18/20 : ADD managed-schema /opt/solr-8.6.3/server/solr/ik_core/conf
---> Using cache
---> f8d6d2dd9ed6
Step 19/20 : USER solr
---> Using cache
---> 989221e33b98
Step 20/20 : WORKDIR /opt/solr-8.6.3
---> Using cache
---> 5d6c68254e72
Successfully built 5d6c68254e72
Successfully tagged solr_solr:latest
Creating solr ... done
所有者和组是相同的。
total 18308
-rw-r--r-- 1 root root 937 Jul 17 13:31 Dockerfile
-rw-r--r-- 1 halloweens halloweens 6 Oct 28 2020 hotword.dic
-rw-r--r-- 1 halloweens halloweens 9686058 Oct 22 2020 ik-analyzer-8.3.0.jar
-rw-r--r-- 1 halloweens halloweens 589 Oct 28 2020 IKAnalyzer.cfg.xml
drwxr-xr-x 4 halloweens halloweens 30 Jul 17 13:18 ik_core
-rw-r--r-- 1 halloweens halloweens 64795 Nov 5 2020 managed-schema
-rw-r--r-- 1 halloweens halloweens 6369473 Oct 3 2020 solr-core-8.6.3.jar
-rw-r--r-- 1 halloweens halloweens 231329 Oct 3 2020 solr-dataimporthandler-8.6.3.jar
-rw-r--r-- 1 halloweens halloweens 41007 Oct 3 2020 solr-dataimporthandler-extras-8.6.3.jar
-rw-r--r-- 1 halloweens halloweens 11858 Jul 17 12:05 solr.in.sh
-rw-r--r-- 1 halloweens halloweens 2311259 Oct 3 2020 solr-solrj-8.6.3.jar
-rw-r--r-- 1 halloweens halloweens 8 Oct 28 2020 stopword.dic
下面是 ik_core 文件夹中的内容。
total 0
drwxr-xr-x 2 halloweens halloweens 6 Jul 17 13:18 conf
drwxr-xr-x 2 halloweens halloweens 6 Jul 17 13:13 data
解决方案
推荐阅读
- php - 获取谷歌日历,“服务帐户无法在没有全域授权的情况下邀请与会者。”
- node.js - 获取 windows 文件信息,如 msi 文件的注释
- r - R 中是否有生成唯一组合及其频率的解决方案?
- service-worker - 使用 workbox 6 生成 ServiceWorker - 如何从“workbox-routing”导入“registerRoute”?
- .net - 从序列生成序列的函数
- html - 如果文本溢出,则 2 个跨度之间的新行
- linux - 如何从今天的日志文件中读取一个单词?在 BASH 中
- vb.net - Datagridview 在表单加载时全黑
- php - 使用 PHPSpreadsheet 时在保留格式的同时将 Excel 文件转换为数组
- java - 使用 GSI 时,DynamoDBmapper 不返回我的所有数据