5
5

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

Last updated at Posted at 2014-07-07

只只コンテナ編集後、イメージ化してませんでしたという落ちなので、
こちらをご覧になると良いかと思います。

個人的な備忘録として。

コンテナにssh接続

コンテナを作成

$ docker run -it intern/base /bin/bash
root@8687f7b2a78a:/# 

ユーザ追加

root@8687f7b2a78a:/# useradd -m -G sudo docker
root@8687f7b2a78a:/# passwd docker
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

root@8687f7b2a78a:/# 

sshd_configの設定

ごにょごにょ。

イメージ化

$ docker ps -a
CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS                      PORTS               NAMES
8687f7b2a78a        intern/base:latest   /bin/bash           2 days ago          Exited (0) 29 seconds ago                       cocky_archimedes    

$ docker commit 868 intern/sshd
c50b5f4e9a010e2b7fd119af181c71a28471f85104a5a4f155ec4c40f04804b9

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
intern/sshd         latest              c50b5f4e9a01        2 days ago          409.3 MB
intern/base         latest              18d571447ec6        2 days ago          408.9 MB

$

コンテナを作り、ssh接続する

$ docker run -d -p 22 --name sshd_test intern/sshd /usr/sbin/sshd -D
be90b1655e0b277a65d6f96d2741364d6f6789a9ba8302dd1abf2045b124cb75

$ boot2docker ip
The VM's Host only interface IP address is: 192.168.x.x

$ docker ps
CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS                   NAMES
be90b1655e0b        intern/sshd:latest   /usr/sbin/sshd -D   2 days ago          Up 51 seconds       0.0.0.0:49153->22/tcp   sshd_test

$ ssh -p 49153 docker@192.168.x.x
docker@192.168.x.x's password: 
Linux viper 3.12.22-gentoo #1 SMP Tue Jun 17 20:39:22 MDT 2014 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

$ 

続く

参考文献

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?