docker + flask を linux mint 19.1 に移植

オフラインの linux mint 19.1 に他の linux min 20.3 で作成した docker + flask を移植します。

移植元で docker イメージの書き出し

まず確認し、


docker images

REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
flask         latest    1bcaa98e7e2e   2 hours ago    59.7MB
python        alpine    2c167788a673   13 days ago    47.8MB

2つとも書き出します。


docker save flask > flask.tar

docker save python > python.tar

この 2 つのファイルと作った python プログラムを linux mint 19.1 のホームディレクトリに移動します。

python プログラムは移植のことを考えて、今回は最初から /opt 以下に作成しました。

移植先でイメージを load する

移植先の linux mint 19.1 のコマンドラインで、


docker save flask < flask.tar

docker save python < python.tar

確認。


docker images

REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
flask         latest    1bcaa98e7e2e   2 hours ago    59.7MB
python        alpine    2c167788a673   13 days ago    47.8MB

作成したプログラムの配置

linux mint 20.3 で作成したプログラムを配置します。

linux mint 20.3 では /opt 以下に作成したので、移植先の linux mint 19.1 でも /opt 以下に配置します。


sudo mv ~/test /opt

起動する

ビルドされたイメージからcontainer を作成して起動します。


docker container run -p 5000:80 -it flask:latest

アドレスバーに「http://localhost:5000/」で確認できます。