我的目標是使用 docker 處理一個專案,而不必在每次稍微修改檔案時不斷重建我的整個專案:
下面的檔案(未完成)有 2 個狀態,一個已經更新的版本,我將其稱為
Version_0,看起來像這樣 :
<#modelInf> rdf:type ja:InfModel ;
# ja:content [ja:externalContent <file:/fuseki/ontologies/server_famille.ttl> ; ] ;
ja:reasoner [
ja:reasonerClass "openllet.jena.PelletReasonerFactory" ; ]
.
更新后它運行良好,但后來我決定取消注釋一行,我將呼叫這個檔案Version_1:
<#modelInf> rdf:type ja:InfModel ;
ja:content [ja:externalContent <file:/fuseki/ontologies/server_famille.ttl> ; ] ;
ja:reasoner [
ja:reasonerClass "openllet.jena.PelletReasonerFactory" ; ]
.
我的 dockerfile 的重要部分如下所示:
FROM [...]
RUN mkdir -p /fuseki
RUN mkdir -p /fuseki/configuration/
WORKDIR /fuseki
COPY server/configuration/db_tdb.ttl configuration
我還運行了一個 docker-compose 檔案 [已編輯]
version: "3"
services:
jena-fuseki-server:
hostname: jena-fuseki
build:
context: .
dockerfile: server.Dockerfile
restart: always
ports:
- 3030:3030
environment:
- ADMIN_PASSWORD=admin
- FUSEKI_DATASET_1=ds
command: cat /fuseki/configuration/db_tdb.ttl
問題似乎是我第一次運行$docker-compose up --build它運行良好并正確復制Version_0,修改后,我重新運行$docker-compose up --build并且我希望Version_1 是復制的檔案。發生的情況是,在驗證導航我的影像docker exec -it [name] bash并執行之后cat db_tdb.ttl,它仍然顯示我Version_0。測驗我的應用程式確認Version_0是正在運行的應用程式。
[已編輯]cat我添加的命令顯示Version_0也是復制的
你試過什么?
- 命令
docker-compose build --no-cache后跟docker-compose up
結果:不起作用并且沒有完成我想要的。 - The command
docker system prune -afollowed bydocker-compose up --build
result: it did work but doesn't accomplish what I want. - I also tried to target the configuration folder instead of the file itself
result: no noticeable changes. - Adding a
RUN rm -f configuration
result: no noticeable changes - [Edited] Run :
docker-compose up --build --force-recreate
result : no noticeable changes
Honorable mentions
- During my project, I did not always have this issue.
- When I use
docker-compose up --buildit uses the cache except for the modified file yet still doesn't work
Since it is a big project, I can't resolve myself to run docker system prune -a or using --no-cache as it would result in a HUGE lost of time.
I feel like it worked at some point but I can't understand the reason nor give it consistancy.
Thanks you.
uj5u.com熱心網友回復:
嘗試做docker-compose down后跟docker-compose up --build.
似乎洗掉容器首先修復了一些隱藏的快取問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/347903.html
