MacOS set left Alt as ‘Meta’

  1. Go in Menu bar Iterm2 => Preferences => Profiles
  2. choose the keys tab and select left Option key act as +Esc

Screen Shot 2017-10-19 at 09.39.58

 

Kudos to:

https://stackoverflow.com/questions/196357/making-iterm-to-translate-meta-key-in-the-same-way-as-in-other-oses

 

Advertisements

Reset Docker Local Env Vars

When you are playing with Docker Machine and Docker beta at the same time on the same host you may get some errors like:

Could not read CA certificate “/Users/<USER>/.docker/machine/machines/default/ca.pem”: open /Users/<USER>/.docker/machine/machines/default/ca.pem: no such file or directory

If that’s the case, your ENV vars are probably still set to use some Docker Machine setup, you can check it with the following command:


env|grep DOCKER

Then


unset $(env|grep DOCKER|awk -F'=' '{print $1}')

 

Docker 1.12.1 (swarm) notes

Please note this assumes there is a swarm >= 1.12 cluster up and running 

# get docker logs on instances

journalctl -fu docker

# services

docker service ls 

docker service ps <service>

# if health check enabled

docker inspect –format='{{json .State.Health}}’ <container>

# scale

docker service scale nginx=10

# get all manager’s IPs

docker node inspect $(docker node ls|grep -v HOSTNAME|tr -d ‘*’|awk ‘{print $2}’)|grep Addr

docker service inspect -f ‘{{json .Endpoint.VirtualIPs}}’ <SERVICE NAME>

# nodes

docker node ls 

# draining

docker node update –availability drain <nodeID>

# reactivate

docker node update –availability active <nodeID>

# create 5 replicas in swarm cluster for hello-world service

# curl the nodes and check even load balancing 

while true; do for i in <CLUSTER NODES IP SUFFIXES LIST> ; do curl -s http://172.24.$i/|grep -i hostname  ; sleep .1 ; done ; done | tee -a /tmp/aaa

cat  /tmp/aaa| sort|uniq -c

 

Docker 1.12 Health Check

Can be used inside Dockerfile:

HEALTHCHECK --interval=5m --timeout=3s \ 
CMD curl -f http://localhost/ || exit 1

 

or with docker run:

  --health-cmd            Command to run to check health
  --health-interval       Time between running the check
  --health-retries        Consecutive failures needed to report unhealthy
  --health-timeout        Maximum time to allow one check to run
  --no-healthcheck        Disable any container-specified HEALTHCHECK

Example:

$ docker run --name=test -d \
    --health-cmd='stat /etc/passwd || exit 1' \
    --health-interval=2s \
    busybox sleep 1d
$ sleep 2; docker inspect --format='{{.State.Health.Status}}' test
healthy
$ docker exec test rm /etc/passwd
$ sleep 2; docker inspect --format='{{json .State.Health}}' test
{
  "Status": "unhealthy",
  "FailingStreak": 3,
  "Log": [
    {
      "Start": "2016-05-25T17:22:04.635478668Z",
      "End": "2016-05-25T17:22:04.7272552Z",
      "ExitCode": 0,
      "Output": "  File: /etc/passwd\n  Size: 334       \tBlocks: 8          IO Block: 4096   regular file\nDevice: 32h/50d\tInode: 12          Links: 1\nAccess: (0664/-rw-rw-r--)  Uid: (    0/    root)   Gid: (    0/    root)\nAccess: 2015-12-05 22:05:32.000000000\nModify: 2015..."
    },
    {
      "Start": "2016-05-25T17:22:06.732900633Z",
      "End": "2016-05-25T17:22:06.822168935Z",
      "ExitCode": 0,
      "Output": "  File: /etc/passwd\n  Size: 334       \tBlocks: 8          IO Block: 4096   regular file\nDevice: 32h/50d\tInode: 12          Links: 1\nAccess: (0664/-rw-rw-r--)  Uid: (    0/    root)   Gid: (    0/    root)\nAccess: 2015-12-05 22:05:32.000000000\nModify: 2015..."
    },
    {
      "Start": "2016-05-25T17:22:08.823956535Z",
      "End": "2016-05-25T17:22:08.897359124Z",
      "ExitCode": 1,
      "Output": "stat: can't stat '/etc/passwd': No such file or directory\n"
    },
    {
      "Start": "2016-05-25T17:22:10.898802931Z",
      "End": "2016-05-25T17:22:10.969631866Z",
      "ExitCode": 1,
      "Output": "stat: can't stat '/etc/passwd': No such file or directory\n"
    },
    {
      "Start": "2016-05-25T17:22:12.971033523Z",
      "End": "2016-05-25T17:22:13.082015516Z",
      "ExitCode": 1,
      "Output": "stat: can't stat '/etc/passwd': No such file or directory\n"
    }
  ]
}

Refs:

https://docs.docker.com/engine/reference/builder/#/healthcheck

https://docs.docker.com/engine/reference/run/#/healthcheck

http://stackoverflow.com/questions/38842914/health-check-command-for-docker1-12-container-not-in-dockerfile