1
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 5 years have passed since last update.

dockerの既存コンテナをベースに新規コンテナを作成する

Posted at

目的

dockerの既存コンテナをベースに新規コンテナを作成する


問題

コンテナを作成ごとに種々をインストールして設定するのが大変


解決策

一度設定したコンテナを使い回す


方法

exportしたいコンテナをストップ

docker stop コンテナID

exportする

docker export コンテナID > 名前.tar

importする

docker import 名前.tar 名前:タグ名

importできたか確認

docker images

importしたものを土台にしてコンテナを作成

docker run --privileged -it -d -p 8888:8000 -p 12345:22 --name コンテナ名 イメージID /sbin/init

オプション

--privileged
起動するコンテナに権限を与えることができる。

-i
標準入力(STDIN)を開いたままにする

-t
擬似ttyに接続する。ディスプレイ(STDOUT)をつなぐイメージ

-d
停止しても自動的に削除されない

--name
コンテナ名を指定することができる

よく使うDockerコマンド
http://qiita.com/noralife/items/18301143c20cc5172c56


ポート番号

ポート番号
http : 80
https : 443
ssh : 22


TCPやUDPにおけるポート番号の一覧
https://ja.wikipedia.org/wiki/TCP%E3%82%84UDP%E3%81%AB%E3%81%8A%E3%81%91%E3%82%8B%E3%83%9D%E3%83%BC%E3%83%88%E7%95%AA%E5%8F%B7%E3%81%AE%E4%B8%80%E8%A6%A7

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?