1
0

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-composeのコンテナ名がランダム化になって困った時の対応

Last updated at Posted at 2018-12-13

https://github.com/docker/compose/releases/tag/1.23.2
1.23.2のバージョンでコンテナ名のランダム文字列の付与が無くなりました。
1.23.1だけの幻の機能だったようです・・・・。

以下、docker-compose v1.23.1をお使いの方だけ対象の記事になります。

Macのdocker-composeを使って開発していたのですがバージョンアップしたらdocker-composeで立ち上がるコンテナ名が

docker-dev_web-service_1

という名前が

docker-dev_web-service_1_7871912c2b4d

のようなハッシュが付くようになってしまいました。

docker-compose down && docker-compose up -d

で作り直すことが多いので名前が変わると面倒になってしまいました。

いちいちdocker-compose psやらなくても良いように以下のコマンドを叩くようにしました。

docker exec -it $(docker ps -f name=web-service -q) sh

さらにdockerコマンドのエイリアスが設定されていれば

dkE $(dkps -f name=web-service -q) sh

というコマンドで済みます。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?