8
8

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入門: 2日目

Last updated at Posted at 2014-07-04

Debianにごにょごにょ

コンテナを起動、接続

コンテナ一覧を確認。
(1日目のコンテナは削除し、別のコンテナを作っているので、前記事とコンテナIDが違ってます...すみません)

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                       PORTS               NAMES
a4d504a59714        debian:latest       /bin/bash           3 minutes ago       Exited (127) 1 seconds ago                       sleepy_fermi

$

コンテナa4d504a59714を起動後、実行中のコンテナ一覧を確認。

$ docker start a4d
a4d

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
a4d504a59714        debian:latest       /bin/bash           5 hours ago         Up 16 seconds                           elegant_archimedes 

$

コンテナa4d504a59714に接続。

$ docker attach a4d

root@a4d504a59714:/# 

いろいろインストール

$ docker run -it debian /bin/bash
root@a4d504a59714:/# apt-get update
...
Reading package lists... Done

root@a4d504a59714:/# apt-get upgrade
...
upgraded.

root@a4d504a59714:/# apt-get -y aptitude
...
root@a4d504a59714:/# apt-get -y ssh
...
...
...
root@a4d504a59714:/# 

イメージを作る

コンテナからイメージを作る

基本的なソフトウェアを入れたので、コンテナa4d504a59714をイメージにしておきます。
今後の課題でやらかしても帰ってこれるように...。

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
a4d504a59714        debian:latest       /bin/bash           7 hours ago         Exited (0) 8 minutes ago                       elegant_archimedes  

$ docker commit a4d intern/base
18d571447ec6d2951054872f04d9192e84b4081d0c9172efa51f2defe6787fad

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
intern/base         latest              18d571447ec6        40 seconds ago      408.9 MB
debian              latest              63f650c4db34        2 days ago          85.18 MB

イメージintern/baseからコンテナを作る

ポートフォワーディングしてみたり。

$ docker run -p 22 -it intern/base /bin/bash
root@1428cee52ef3:/# 

IMAGE項目が変わってる。

$ docker ps -a
CONTAINER ID        IMAGE                COMMAND             CREATED              STATUS                      PORTS               NAMES
1428cee52ef3        intern/base:latest   /bin/bash           About a minute ago   Exited (0) 50 seconds ago                       high_lumiere         
a4d504a59714        debian:latest        /bin/bash           8 hours ago          Exited (0) 16 minutes ago                       elegant_archimedes   

$

続く

ひとまず基本的なところは終わり。

Docker入門: 3日目

参考

8
8
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
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?