Docker Desktop for Windows が管理する docker イメージのバックアップおよびリストアの方法。
バックアップ
バックアップ対象イメージの特定
どのイメージをアーカイブするのか、予め特定しておく。
※ 確実なリストアにつなげる為には、[REPOSITORY]:[TAG]の形式でイメージを特定しておくと良い。
※ 複数のdocker イメージを1つのアーカイブ・ファイルに保存可能。
PS> docker.exe images
バックアップする
バックアップ対象のイメージを、tarファイルにアーカイブする。
PS> docker.exe image save --output|-o <tarファイル名> <REPOSITORY1:TAG1> [REPOSITORY2:TAG2] ...
例
PS> docker.exe images
REPOSITORY TAG IMAGE ID CREATED SIZE
wordpress 5.8-php7.4-apache 6aa7a57ff7b3 5 months ago 618MB
mysql 5.7 738e7101490b 5 months ago 448MB
alpine latest c059bfaa849c 5 months ago 5.59MB
phpmyadmin/phpmyadmin latest 2e5141bbcbfb 11 months ago 474MB
mysql 5.7.28 db39680b63ac 2 years ago 437MB
PS> docker.exe image save -o .\images.tar wordpress:5.8-php7.4-apache mysql:5.7 phpmyadmin/phpmyadmin:latest
リストア
バックアップした アーカイブファイル(tar) を使用し、docker イメージとしてインポートする。
docker 内に既に存在する場合には上書きされないため、予め削除しておく必要がある。
既存イメージ削除
既存イメージを削除する場合には、以下のコマンドを発行する。
PS> docker.exe image rm [--force|-f] <REPOSITORY1:TAG1> [REPOSITORY2:TAG2] ...
リストア
バックアップした アーカイブファイル(tar) を使用し、docker イメージとしてインポートする。
PS> docker.exe image load --input|-i <tarファイル名>