Monday, June 19, 2017

Find a File with Certain Contents

I was trying to search for a file with a particular class name inside it, and I could not remember the syntax of the command to save my life.  I knew I had it in a note somewhere, but I couldn't find that either.

Tonight I found the note.  I'm posting the command here so I can find it again.

For linux:
find . -name 'filepattern' -exec grep -l 'contentpattern' {} \;
For Powershell:
Get-ChildItem -Recurse | Select-String "dummy" -List | Select Path

Friday, June 2, 2017

Running Apps in Docker for Mac

In an earlier post I wrote instructions for running graphical applications out of Docker containers on my Mac. Since I wrote that post, I have wiped my Mac and reinstalled everything, including Docker for Mac. This post is an update of those instructions.

The steps for running graphical applications from Docker on a Mac have simplified quite a bit. These instructions assume you have Docker for Mac installed and running and have access to container images. Without further ado, here are the instructions:

  1. Install XQuartz from https://www.xquartz.org/. This MUST be done. The separate installation is required for the graphical applications to run on the Mac host from a Docker container.
  2. Logout and log back into the Mac. This is necessary to use XQuartz.
  3. Open XQuartz. From a terminal, execute the following command:
    open -a XQuartz
  4. In the XQuartz terminal window, execute the command:
    xhost +
    This command may be a little insecure; I haven't researched it fully yet.
  5. Run your Docker container, passing the DISPLAY environment variable with a command like:
    docker run --rm -it -e DISPLAY=192.168.1.1:0 ubuntu:latest /bin/bash
    192.168.1.1 is a sample IP address. Use the IP address of your system there.
  6. Within the Docker container, run an application with a graphical interface. This should display on the Mac.
  7. Enjoy!