Docker container - yank text using xclip

740 Views Asked by At

I am having issues related with xclip in a docker container.

echo "text" | xclip

which raises the error: Error: Can't open display: (null).

How can I programmatically add some text to host's clipboard from the container (in an OS independent way if possible)?

Thank you in advance.

UPDATE

DISPLAY env variable is not set. How can I set it correctly?

1

There are 1 best solutions below

0
On

Not OS independent, but you can mount your host's X11 socket:

docker run --volume /tmp/.X11-unix:/tmp/.X11-unix --env DISPLAY=$DISPLAY -it CONTAINER

More info: http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/