9
4

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.

docker exec -ti ~~ bashを省略する

Last updated at Posted at 2016-11-21

Dockerコンテナに入るコマンド、叩くの面倒ですよね。

docker exec -ti hogehoge bash

ということで、以下を/etc/bashrcに追記しました

function dbash() { docker exec -ti $1 bash; }

使用例

[root@localhost ~]# docker run -d --name test  centos tail -f /dev/null
b3df9b104fb02a7c04c375762de8807783e02aff11a1d2350fb5171297619a5b
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND               CREATED             STATUS              PORTS               NAMES
b3df9b104fb0        centos              "tail -f /dev/null"   2 seconds ago       Up 1 seconds                            test
[root@localhost ~]# dbash test
[root@b3df9b104fb0 /]#
[root@b3df9b104fb0 /]#

(良し悪しはありますが)まっさらな開発環境としてDockerを使うことがあるので、そこそこ重宝しています

9
4
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
9
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?