Thursday, October 10, 2019

Docker CLI commands, most used by me

Docker command docker, used when managing individual containers on a docker engine. It is the client command line to access the docker daemon API

docker build - build an image from Dockerfile
docker container - manage one or more docker containers, takes a second argument (ps, rm, etc...)
docker exec - run a command in a running container
docker images - list all docker images
docker info - display a ton of system info for all docker containers
docker port - list port mappings, possibly for a single container
docker ps - list all docker containers
docker rm - remove one or more docker containers
docker rmi - remove one or more docker images
docker run - run d command in a new docker container

Docker command docker-compose, used to manage a multi-container application. It also moves many of the options you would enter on the docker run CLI into the docker-compose.yml file for easier reuse. It works as a front end "script" on top of the same docker API used by docker, so you can do everything docker-compose does with docker commands and a lot of shell scripting

docker-compose build - build or rebuild services
docker-compose exec - execute a command in a running container
docker-compose help - get help in
docker-compose images - list images
docker-compose ps - list containers
docker-compose up - build and start containers
docker-compose version - docker-compose version number

Docker command docker-machine, uses containerization to manage multiple images and containers and volumes and such: a container is basically a lightweight virtual machine

docker-machine create - create a new virtual machine
docker-machine env - display the commands to set up the environment for the Docker client
docker-machine kill - kill a machine
docker-machine ls - list all machines
docker-machine regenerate-certs - regenerate TLS certs for a machine
docker-machine restart - restart a machine
docker-machine rm - remove a machine
docker-machine ssh - log into or run a command on a machine with ssh
docker-machine start - start a machine
docker-machine version - show the docker machine version number

Monday, July 22, 2019

Removing an application manually from OS/X

After looking this up a million times, time to add it here...

  • rm -rf /Applications/APPNAME
  • rm -rf ~/Library/Preferences/APPFILES
  • rm -rf ~/Library/Caches/APPFILES
  • rm -rf ~/Library/Application\ Support/APPFILES
  • rm -rf ~/Library/Logs/APPFILES

Friday, December 28, 2018

Mapping capslock to an extra control key in Xorg

Edit /etc/default/keyboard and add the following:

XKBOPTIONS="ctrl:nocaps"

Then run:

sudo dpkg-reconfigure keyboard-configuration

Friday, November 23, 2018

Convert epoch to human readable datetime

  • Linux: date -d @1316645223
  • BSD and MacOS: date -r 1316645223
Both return -> Wed Sep 21 15:47:03 PDT 2011

Friday, August 31, 2018

Pretty print JSON from command line

echo '{ "element0" : "hi", "element1" : "there" }' | python -m json.tool
prints:
{
    "element0": "hi",
    "element1": "there"
}
You can also cat a JSON file and pipe to the same command

Ansible become_user for a block of commands

use a block to apply a become_user to a block of commands
- block:
    - name: checkout repo
      git:
        repo: https://github.com/some/repo.git
        version: master
        dest: "{{ dst }}"
    - name: change perms
      file:
      dest: "{{ dst }}"
      state: directory
      mode: 0755
      owner: some_user
  become: yes
  become_user: some user

Saturday, June 10, 2017