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.

Dockerホストとnginxコンテナでフォルダ共有

Last updated at Posted at 2023-01-08

環境

VirtualBox6.1
ホストOS: Windows10 Home 20H2
ゲストOS: Ubuntu20.04 + Docker20.10.22 + nginx1.23.3

Dockerホストのhtmlフォルダをnginxコンテナと共有する

docker run -vオプション(VOLUMEオプション)を使う

docker run -v /home/nacanaca/dockertest/www/html:usr/share/nginx/html --name mynginx -p 8080:80 nginx

※/usr/share/nginx/html は nginxのデフォルト公開ディレクトリ

エラーが出た…。

nacanaca@admin-VirtualBox:/var/www/html$ docker run -v /home/nacanaca/dockertest/www/html:usr/share/nginx/html  --name mynginx -p 8080:80 nginx
docker: Error response from daemon: invalid volume specification: '/home/nacanaca/dockertest/www/html:usr/share/nginx/html': invalid mount config for type "bind": invalid mount path: 'usr/share/nginx/html' mount path must be absolute.
See 'docker run --help'.

※絶対パス【absolute path】フルパス

usrの前に/が漏れていました。

正しくは
docker run -v /home/nacanaca/dockertest/www/html:/usr/share/nginx/html --name mynginx -p 8080:80 nginx

参考にしたサイト

dockerのバインドマウント時のエラー
https://frazz.hatenablog.jp/entry/2021/04/07/232036

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?