5
6

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.ymlを実行する方法

Posted at

例えば、ルートディレクトリから/docker ディレクトリーのdocker-compose.ymlを利用したい場合があったとする

root/
 └ docker/
   ├ Dockerfile
   └ docker-compose.yml

そのとき、このようなコマンドで実行できる

docker-compose -f ./docker/docker-compose.yml run --rm build-hogehoge

Dockerを走らせるコマンドって長くなりがちなので、docker-compose.ymlに記載して叩くことも最近よくある

その時にもわざわざディレクトリの移動しなくても良くなるので、結構便利

例えばこんな感じのroot/docker/docker-compose.ymlを書いて

version: "3.3"
services:
  build-hogehoge:
    image: alpine
    command: echo build-hogehoge
    volumes:
      - .:/work
    workdir:
      /work

  run-something:
    image: alpine
    command: echo run-something "run"
docker-compose -f ./docker/docker-compose.yml run --rm build-hogehoge
docker-compose -f ./docker/docker-compose.yml up -d run-something
5
6
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
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?