Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing from inside a docker container

Tags:

docker

cups

With the influx of GUI applications being ported to docker, what is the best way to print to cups from inside a docker container?

NB: I am not looking to run cups from inside the container as this breaks the single service paradigm associated with docker.

like image 571
Chris Daish Avatar asked Jun 24 '15 15:06

Chris Daish


People also ask

What is difference between CMD and entrypoint?

Differences between CMD & ENTRYPOINT CMD commands are ignored by Daemon when there are parameters stated within the docker run command while ENTRYPOINT instructions are not ignored but instead are appended as command line parameters by treating those as arguments of the command.

Can you develop inside a docker container?

Developing inside a Docker container generally means starting a container and leaving it running, while you edit your source code. As you make changes, you see the changes appear in the container. To get your source code inside a container, you can use something called a bind mount.

Can a container run multiple images?

Multiple containers can run simultaneously, each based on the same or different images. Docker is similar to virtual machines in the way it creates multiple instances of an operating system.

Can Java run on docker?

You can use Docker to run a Java application in a container with a specific runtime environment.


1 Answers

Self Documenting after investigation work on how to achieve this goal.

Mounting in the cups socket worked great...ish (acroread failed to populate printers) with an Ubuntu based docker host, however this failed with a Redhat host.

...
-v /var/run/cups:/var/run/cups:ro
...

Populating the cups client.conf appeared to be a better solution.

cat /tmp/client.conf

#The ServerName directive specifies sets the remote server 
# that is to be used for all client operations. That is, it 
# redirects all client requests to the remote server. The 
# default port number is 631 but can be overridden by adding
# a colon followed by the desired port number to the value.
# The default is to use the local server ("localhost").
ServerName <DOCKER0 BRIDGE IP>

and the docker launch argument:

...
-v /tmp/client.conf:/etc/cups/client.conf:ro \
...

I also had to ensure the cups server would bind to the docker0 bridge and allow other devices to access the cups server:

...
Listen *:631
...
<Location />
  Order allow,deny
  Allow all
</Location>
...

Once cups had restarted and the cups client.conf passed into the container I was able to print as expected.

like image 67
Chris Daish Avatar answered Sep 23 '22 22:09

Chris Daish