12
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

peco で docker exec

Last updated at Posted at 2016-02-18

開発中に Docker コンテナに入りたい事がたびたびあるので, 下の方法で入っていたのですが毎回大変なので.
コンテナに入りたい?それ docker exec でできるよ

 % docker exec -it `docker ps| peco | cut -d" " -f 1` /bin/bash
root@123456789abc:/#

peco に流した時に Docker PS のヘッダが邪魔なので出ないようにします.

 % docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS         NAMES  # <- Headerが邪魔
123456789abc        hoge/hoge             "/bin/bash -c ..."       2 minutes ago       Up 2 minutes        ....          ....
...

% docker ps --format "{{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Command}}\t{{.RunningFor}}"
123456789abc    hoge/hoge    Up 1 minutes    "/bin/bash -c ..."    1 minutes
...

aliasにも登録しておきました

.zshrc
alias ddps='docker ps --format "{{.ID}}\t{{.Image}}\t{{.Status}}\t{{.Command}}\t{{.RunningFor}}"'
alias ddexec='docker exec -it `ddps | peco | cut -f 1` /bin/bash'
12
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?