Currently Browsing: Mac Tech

Docker for Mac fix for max files, transparent hugepages warnings

To avoid Redis and other apps’ “max files limit” and “transparent hugepages” etc errors in Docker containers on Docker for Mac, you can set sysctls options in your docker-compose file by using compose format 2.1 or greater, which should be supported in docker-compose >= 1.10.

in docker-compose.yml file:

version: '2.1'
    image: redis:3.2-alpine
    command: redis-server /usr/local/etc/redis/redis.conf
      - net.core.somaxconn=1024

To update transparent hugepages settings in Docker for Mac’s Alpine hypervisor host system, you can use this hack:

docker run --rm --privileged -ti alpine /bin/sh -c "echo never > /sys/kernel/mm/transparent_hugepage/enabled && echo never > /sys/kernel/mm/transparent_hugepage/defrag"

In theory you wouldn’t need/want to do this on a production host as you would configure the host properly. If you update Docker, you will need to re-run this.

JSON parsing from the command-line

You don’t need to use Python for basic JSON parsing, just use `jq`:

jq – Command-line JSON processor


  • etc.

    Permanently show hidden folders in MacOS

    Even when I copied an old filesystem, the Library directories were hidden in the finder. To show them, use:

    chflags nohidden ./Library

    Find Mac Library prefs files

    Recently got a new laptop and needed to copy some prefs and config files over. Command to search for the files:

    find ./Library -name '*searchterm*'

    You can then pipe this to copy script or similar.

    I’ve also used rsync in the past but filtering with just rsync is a bit tricky.

    Connect to Docker for Mac Alpine Host

    The new Docker for Mac (mid-2016) doesn’t work the same way as previous versions or the native linux version. To interact with the Docker Host VM, instead of SSH, you can use:

    screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

    and login with root user. No password should be required.
    use Control-a d to detach.

    You can also get networking, etc info about the host by querying a container host-networked like so:

    docker run --rm --privileged --net=host alpine ifconfig

    « Previous Entries