Skip to content

ConorSheehan1/osxdocker

Repository files navigation

Build Status Documentation Status PyPI PyPI - License Code style: black

osxdocker

A CLI for working with docker on OSX

Currently it just handles docker logs, because I found it annoying starting up a screen session to get to the docker vm every time I wanted to clear logs. See: https://stackoverflow.com/questions/42527291/clear-logs-in-native-docker-on-mac

Install

# installs osxdocker and recommended docker and screen dependencies
brew install conorsheehan1/conorsheehan1/osxdocker

# installs osxdocker cli only, assumes you have docker and screen on your path
pip3 install osxdocker

Usage

# clear logs
osxdocker clear_log $some_container_name

# list available commands and flags
osxdocker

clear_log_example

This cli uses https://github.com/google/python-fire
Check out the docs for more details on usage, setting up bash completion, etc.
Also worth noting:

  1. Because the package uses fire, it can be imported like a normal python package. e.g.
    from osxdocker.docker_logs import DockerLogs
    DockerLogs().log_path('foo')
  2. This cli doesn't support --version due to a quirk with fire.
    osxdocker version # works fine
    osxdocker --version # won't work

Edge cases and gotchas

Container names are unique, but containers are filtered by regex, so you can still run into issues.
e.g. You have two containers, named foo and foo_too.
osxdocker cat_log foo will fail because it matches foo and foo_too.
osxdocker cat_log ^foo$ will work because it matches foo exactly.

multiple_container_error

Developer notes

See docs/source/dev.md