Laradock 安装 PDFtk
Laradock install PDFtk
我正在尝试为 laradock(php-fpm 和工作区)安装 pdftk,但是找不到 Ubuntu 20.04 的 pdftk。所以我尝试创建一个新容器,但我不知道如何从其他容器调用它,比如 php-fpm 和工作区。
# Dockerfile
FROM ubuntu:16.04
USER root
ARG TOP_LEVEL_DIR="pdftk"
RUN apt-get update && \
apt-get -y install \
pdftk && \
mkdir -p /${TOP_LEVEL_DIR}
WORKDIR /var/www
ENTRYPOINT ["/usr/bin/pdftk"]
CMD [ "/bin/bash" ]
# docker-composer.yml
### pdftk ###############################################
pdftk:
image: pdftk
container_name: pdftk
build:
context: ./pdftk
volumes:
- ${PWD}:/pdftk
- /var/run/docker.sock:/var/run/docker.sock
tty: true
depends_on:
- workspace
networks:
- backend
非常感谢
您应该为php-fpm
定义音量- /var/run/docker.sock:/var/run/docker.sock
,而不是pdftk
,同时,您最好定义音量- /usr/bin/docker:/usr/bin/docker
。
然后在你的 php-fpm
中,你可以使用 docker exec -it php-fpm /usr/bin/pdftk
调用 pdftk
。
补充,pdftk
其实确实存在于ubuntu:20.04
,请再次确认。
Dockerfile:
FROM ubuntu:20.04
RUN apt-get update && apt-get -y install pdftk
执行:
$ docker build -t abc:1 .
Setting up pdftk-java (3.0.9-1) ...
update-alternatives: using /usr/bin/pdftk.pdftk-java to provide /usr/bin/pdftk (pdftk) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/pdftk.1.gz because associated file /usr/share/man/man1/pdftk.pdftk-java.1.gz (of link group pdftk) doesn't exist
Setting up pdftk (2.02-5) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for ca-certificates (20210119~20.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
$ docker run --rm -it abc:1 pdftk --version
pdftk port to java 3.0.9 a Handy Tool for Manipulating PDF Documents
Copyright (c) 2017-2018 Marc Vinyals - https://gitlab.com/pdftk-java/pdftk
Copyright (c) 2003-2013 Steward and Lee, LLC.
pdftk includes a modified version of the iText library.
Copyright (c) 1999-2009 Bruno Lowagie, Paulo Soares, et al.
This is free software; see the source code for copying conditions. There is
NO warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
我正在尝试为 laradock(php-fpm 和工作区)安装 pdftk,但是找不到 Ubuntu 20.04 的 pdftk。所以我尝试创建一个新容器,但我不知道如何从其他容器调用它,比如 php-fpm 和工作区。
# Dockerfile
FROM ubuntu:16.04
USER root
ARG TOP_LEVEL_DIR="pdftk"
RUN apt-get update && \
apt-get -y install \
pdftk && \
mkdir -p /${TOP_LEVEL_DIR}
WORKDIR /var/www
ENTRYPOINT ["/usr/bin/pdftk"]
CMD [ "/bin/bash" ]
# docker-composer.yml
### pdftk ###############################################
pdftk:
image: pdftk
container_name: pdftk
build:
context: ./pdftk
volumes:
- ${PWD}:/pdftk
- /var/run/docker.sock:/var/run/docker.sock
tty: true
depends_on:
- workspace
networks:
- backend
非常感谢
您应该为php-fpm
定义音量- /var/run/docker.sock:/var/run/docker.sock
,而不是pdftk
,同时,您最好定义音量- /usr/bin/docker:/usr/bin/docker
。
然后在你的 php-fpm
中,你可以使用 docker exec -it php-fpm /usr/bin/pdftk
调用 pdftk
。
补充,pdftk
其实确实存在于ubuntu:20.04
,请再次确认。
Dockerfile:
FROM ubuntu:20.04
RUN apt-get update && apt-get -y install pdftk
执行:
$ docker build -t abc:1 .
Setting up pdftk-java (3.0.9-1) ...
update-alternatives: using /usr/bin/pdftk.pdftk-java to provide /usr/bin/pdftk (pdftk) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/pdftk.1.gz because associated file /usr/share/man/man1/pdftk.pdftk-java.1.gz (of link group pdftk) doesn't exist
Setting up pdftk (2.02-5) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for ca-certificates (20210119~20.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
$ docker run --rm -it abc:1 pdftk --version
pdftk port to java 3.0.9 a Handy Tool for Manipulating PDF Documents
Copyright (c) 2017-2018 Marc Vinyals - https://gitlab.com/pdftk-java/pdftk
Copyright (c) 2003-2013 Steward and Lee, LLC.
pdftk includes a modified version of the iText library.
Copyright (c) 1999-2009 Bruno Lowagie, Paulo Soares, et al.
This is free software; see the source code for copying conditions. There is
NO warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.