Skip to content

Instantly share code, notes, and snippets.

@nathanl
Created April 20, 2017 13:38
Show Gist options
  • Save nathanl/35cdef3494f5012321dbbc5471bad910 to your computer and use it in GitHub Desktop.
Save nathanl/35cdef3494f5012321dbbc5471bad910 to your computer and use it in GitHub Desktop.
A few tiny, useful Docker scripts, to be placed in one's `$PATH` and made executable
#!/bin/bash
# Shell into the Docker container with the given name.
# eg: `docker-bash my_app`
# Note: fails if more than one id is returned.
ID=$(docker-id $1)
docker exec -it $ID bash
#!/bin/bash
# Output the id(s) of running Docker containers with the given name.
# eg: `docker-id my_app`
docker ps |grep $1 |cut -d' ' -f 1
#!/bin/bash
# Shell into the Docker container with the given name.
# eg: `docker-sh my_app`
# Note: fails if more than one id is returned.
ID=$(docker-id $1)
docker exec -it $ID sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment