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 1 year has passed since last update.

wsl2+DockerでhtmlフォルダをマウントしてWindowsから編集できるようにする

Last updated at Posted at 2023-04-16

いつも使用する環境ではWindowsからVScodeでdocker上のlinuxファイルを開いていたのに、別環境でやろうとしたらどうしてもうまくマウントできずハマりました。自分で設定したはずなのにずっとやっていなかったらすっかり忘れていたようなので備忘録。

とりあえずwindowsのwslフォルダにマウントするには以下のような感じでOK。

docker run -d --name apache2-test -p 8080:80 -v \\wsl.localhost\Ubuntu-20.04\home\{user}/apache2-test:/var/www/html ubuntu/apache2

今回なぜか上のコマンドでマウントできなかったが、原因はWSL上でコマンドを実行していたから。つまり、Windows terminal→Ubuntuで起動したターミナルで実行していたということ。
正解はPowerShellからコマンドを実行。これでWidnowsからDockerのUbuntuのhtml内のファイルにアクセスできる。
できてしまえば簡単。こんなのでハマる人は他にいないのかも。

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?