I'm trying to install pdftk for laradock (php-fpm and workspace), but pdftk is not found for Ubuntu 20.04. So I try to create a new container, but I don't know how to call it from other containers, like php-fpm and workspace.
# 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
Many thanks
You should define volume - /var/run/docker.sock:/var/run/docker.sock
for php-fpm
, not for pdftk
, meanwhile, you'd better define volume - /usr/bin/docker:/usr/bin/docker
.
Then in your php-fpm
, you could use docker exec -it php-fpm /usr/bin/pdftk
to call pdftk
.
Additional, pdftk
in fact really exist in ubuntu:20.04
, please check again.
Dockerfile:
FROM ubuntu:20.04
RUN apt-get update && apt-get -y install pdftk
Execution:
$ 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.