Skip to content

Instantly share code, notes, and snippets.



Last active Oct 5, 2020
What would you like to do?

You need to have you docker host running with docker-machine as default


  1. Install mycli (

brew install mycli

  1. Clone plugin

git clone $ZSH_CUSTOM/plugins/connect-docker-db

  1. Enable plugin in ~/.zshrc

plugins=(.. connect-docker-db)


> connect-docker-db container-name-with-mysql

Note: You can use <tab> key to show all running containers to select one after the commant connect-docker-db

#compdef connect-docker-db
local -a _1st_arguments
_1st_arguments=(${(f)${:-"$(docker ps --format {{.Names}})"$'\n'}})
_describe "connect-docker-db" _1st_arguments
function docker-database-port() {
docker port $1 3306 | cut -d ":" -f2
function connect-docker-db() {
mycli --host `docker-machine ip` --port `docker-database-port $1` --user root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.