10
7

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.

zshでDocker コンテナに入るのを楽にする TIPS

Last updated at Posted at 2017-09-11

やること

今まで以下のようにログインしてましたが、長々しくて面倒なのでzshのaliasで解決しようと思います。

$ docker exec -it <コンテナ名> bash

やったこと

1. Aliasの設定

~/.zshrc に以下のように書きました。

alias docker-login='(){ docker exec -it $1 bash -lc "su - $2" }'

2. Dockerコンテナに入る

[rootで入る場合]

$ docker-login <コンテナ名>

[ユーザ指定して入る場合]

$ docker-login <コンテナ名> <ユーザ名>

楽になりました。

10
7
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
10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?