Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exposing Docker application to host

Tags:

docker

pdf

centos

I wish to run a legacy application which is compatible with centos6 which no longer has some dependencies maintained and therefore is incompatible with centos7. This application is called pdftk.

I want to (if this is remotely possible) run pdftk within a docker image of centos6 and expose this application to centos7...

The app does a couple of things:

Takes a PDF document as input & form data as input -> fills the PDF with the form data -> outputs the filled in PDF.

The command might look a little like this:

pdftk input.pdf --do-something output.pdf

Would something like this be possible with docker?

So far I have been able to initialise a centos6 image and successfully install pdftk. Any help with the next part (again if possible) would be most appreciated.

Thanks

like image 969
Daniel Pilch Avatar asked Feb 02 '15 23:02

Daniel Pilch


People also ask

What is difference between expose and publishing?

The difference between an exposed port and a published port is that the published port is available on the host, and we can see that in both "HostConfig" and "NetworkSettings". All published ( -p or -P ) ports are exposed, but not all exposed ( EXPOSE or --expose ) ports are published.

Does Docker expose do anything?

An exposed port is a piece of metadata about the containerized application. In most cases, this shows which ports the application is listening to. Docker itself does not do anything with an exposed port. However, when we launch a container, we can use this metadata when publishing the port.


1 Answers

You can write a Dockerfile with Centos6 as base, then install pdftk and any other dependency. Finally use Dockerfile command ENTRYPOINT to set the pdftk as the command of your image, and pass it the arguments you wish. For example (I haven't tested it, it's only an example):

FROM centos:centos6
RUN yum install pdftk
ENTRYPOINT ["/usr/bin/pdftk"]

Then you can build this image. Supposed you call it 'pdftk', you could run the container as: docker run -it --rm pdftk <arguments> -> docker run -it --rm -v ~/my_pdfs:/pdfs pdftk /pdfs/input.pdf --do-something /pdfs/output.pdf

like image 183
Javier Cortejoso Avatar answered Sep 18 '22 21:09

Javier Cortejoso