docker 命令无法从 makefile 中找到文件,但可以直接从 CLI 中找到它

docker 命令无法从 makefile 中找到文件,但可以直接从 CLI 中找到它

在终端中,一旦进入文件所在的目录test.tex,我可以运行以下docker命令:

$ docker run -i --rm --name latex -v "WD":/usr/src/app -w /usr/src/app registry.gitlab.com/islandoftex/images/texlive:latest-with-cache pdflatex test

但是,如果我创建一个makefile包含以下内容的文件:

run-docker:
    docker run -i --rm --name latex -v "$PWD":/usr/src/app -w /usr/src/app registry.gitlab.com/islandoftex/images/texlive:latest-with-cache pdflatex test

在终端中运行以下命令:

$ make run-docker

导致以下错误:

docker run -i --rm --name latex -v "WD":/usr/src/app -w /usr/src/app registry.gitlab.com/islandoftex/images/texlive:latest-with-cache pdflatex test
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
! I can't find file `test'.
<*> test
        
(Press Enter to retry, or Control-D to exit)
Please type another input file name: 
! Emergency stop.
<*> test
        
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on texput.log.
make: *** [makefile:15 : run-docker] Erreur 1

如何解决这个问题(我猜,与 无关LaTeX)?

答案1

变量引用是错误的,您应该$(CURDIR)在 Makefile 中使用:

run-docker:
    docker run -i --rm --name latex -v "$(CURDIR)":/usr/src/app -w /usr/src/app registry.gitlab.com/islandoftex/images/texlive:latest-with-cache pdflatex test

相关内容