0
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 3 years have passed since last update.

バッチファイルでボリュームをマウントした Docker コンテナを起動する方法

Last updated at Posted at 2020-11-07

これは何?

docker コンテナを起動する際、バッチファイルの配置場所を volume としてマウントする方法です。
適当な場所で bash を使いたいときに便利です。

確認環境

Windows 10 (1909)
Docker version 19.03.13

結論

下記バッチファイルを作成し、好きな場所に置く。ダブルクリックで起動する。コンテナに引数を渡したいときは、バッチファイルに D&D する。

launch.bat
@setlocal
@rem container image
@set IMAGE=buildpack-deps:buster
@rem working directry in container
@set WORK=/workspace
@rem ###########################
@cd /d %~dp0
docker run -it --rm -v "%CD%:%WORK%" -w "%WORK%" %IMAGE% %*
@if errorlevel 1 (
  pause
  exit /b %errorlevel%
)
@exit /b 0

IMAGE に起動する docker image 名を設定しています。好きなイメージに書き換えてください。
WORK に mount 先を指定します。コンテナ無いの適当なマウントポイントに書き換えてください。

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