LoginSignup
1
0

More than 1 year has passed since last update.

docker commit しても volume でマウントしたディレクトリはイメージ化されない

Posted at

事象

タイトル通り。

Dockerfile
VOLUME /foo/bar

もしくは

docker-compose.yml
  volumes:
    - /foo/bar

といった記述がある場合、

docker commit <ID> <Tag>

で起動中コンテナをイメージ化しても、マウントされているディレクトリはイメージに含まれない。

コンテナ内でマウントされているボリュームに含まれるデータは、コミット作業に含まれません。
https://docs.docker.jp/engine/reference/commandline/commit.html

対策

ファイルを書き換えて VOLUME させないようにするほかなさそう。
Dockerfile 記載の VOLUME を docker-compose.yml 側で無効化するのはできない模様?
https://ja.stackoverflow.com/questions/40033/docker-compose%E3%81%A7dockerfile%E3%81%AEvolume%E8%A8%AD%E5%AE%9A%E3%82%92%E8%A7%A3%E9%99%A4%E3%81%99%E3%82%8B%E3%81%93%E3%81%A8%E3%81%AF%E5%8F%AF%E8%83%BD%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B

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