Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

436
Vistas
How to yank to host clipboard from inside a Docker container?

I have Vim installed inside a docker container.

I want to yank some text and somehow magically make it available on my host (macOS) clipboard.

Is that even possible?

UPDATE

So to clarify, this is my full use case...

  • docker run ... some container with Vim baked into the image
  • the default CMD will drop me into bash shell
  • I'm mounting an app directory from my host (macOS) into the container
  • from the container I run vim, write some code
  • from vim I want to yank some text and have it in both:
    • the docker system clipboard (so I can paste it into the container shell if I want)
    • the host (macOS) system clipboard (so I can paste it into other host programs; TextEdit or email, whatever)

Now I'm not sure how this works in the sense of the host (macOS) has to use a VM provided by the docker ecosystem in order to run docker in the first place (as macOS is not a Linux based system and as such can't natively run docker containers without an intermediary VM).

So I'm not sure if the tricks for getting content into the docker system clipboard will filter back through to the VM and into the actual (macOS) host.

x11

I've seen people suggest using X11 and mounting its socket file into the docker container, then using xclip (or xsel). I tried this but was unable to get Vim to yank into the appropriate register for xclip to pick up the yanked content. So subsequently I wasn't sure if my attempt to setup and mount x11 worked either:

  • brew install Caskroom/cask/xquartz
  • open -a XQuartz
  • as part of docker run -v /tmp/.X11-unix:/tmp/.X11-unix
  • from inside container apt-get install -y xclip
  • from within vim in the container "*yiw (select the "* selection register and then yiw yank the current word under the cursor) < but seems vim 8 inside of the container has no such register available to yank into? my vimrc that I've mounted into the container already has set clipboard+=unnamed (which is what I've used in the past to get vim to yank to the macOS system clipboard)

Note: if I tried to use xclip directly (just to see how it worked), most of what I tried resulted in Error: Can't open display: (null).

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

It definitely is.

Take a look at https://github.com/wincent/clipper

It's a service that let's you write to clipboard using netcat.

All you would have to do would be to be able to access your machine's localhost from inside a docker container.

over 4 years ago · Santiago Trujillo Denunciar

0

Simply running in a tmux session, then accessing the target Docker container (eg. docker container exec -it myhost bash), allowed me to open the contents with say vim, and use the standard TMUX copy behaviour to send it to the host machine's clipboard. Job done. No need for clipper etc if that is your use case.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda