Skip to content

Instantly share code, notes, and snippets.

@nathanl
Created April 20, 2017 13:38
Show Gist options
  • Select an option

  • Save nathanl/35cdef3494f5012321dbbc5471bad910 to your computer and use it in GitHub Desktop.

Select an option

Save nathanl/35cdef3494f5012321dbbc5471bad910 to your computer and use it in GitHub Desktop.

Revisions

  1. nathanl created this gist Apr 20, 2017.
    7 changes: 7 additions & 0 deletions docker-bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/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
    5 changes: 5 additions & 0 deletions docker-id
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    #!/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
    7 changes: 7 additions & 0 deletions docker-sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/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