LoginSignup
10
9

More than 5 years have passed since last update.

# Docker初心者が、CentOSでアレした手順を書いてみた

Posted at

CentOS 6.5からでDockerが使えるようになったらしい!

Docker はひとつの Linux システムの上で、複数の Linux システムを動かすためのソフトウェアらしいです。
システムの分離には Linux Containers (LXC) を、ファイルシステムまわりには Advanced multi layered unification filesystem (Aufs) をつかっているとのこと。。(この辺りは僕のレヴェルではまだまだ理解できない。)

とりあえず、centOS上にcentOSを立てれる!やってみよう

Mac

今回はvagrantを使ってます。
vagrantは普段から使ってるので余裕です( ー`дー´)キリッ

$ vagrant init opscode-centos65 http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box
$ vagrant up
$ vagrant ssh

centos6.5のboxをダウンロードして、立ち上げて、sshして

CentOS

次はCentOS上での手順などなど

インストール

$ cd /usr/local/src/
$ sudo su
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm を取得中
警告: /var/tmp/rpm-tmp.ig0t00: ヘッダ V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
準備中...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

$ yum -y install docker-io
$ chkconfig docker on
$ service docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:                                       [  OK  ]

Docker で Hello World

ではさっそく Docker を試してみましょう。Docker 公式の centos イメージを使って、コンテナ内で echo を実行してみます。

$ docker run centos /bin/echo "Hello World"
Unable to find image 'centos' (tag: latest) locally

初回はcentosのイメージが見つからないから時間がかかります。

Pulling repository centos
539c0211cd76: Download complete 

おわったぁぁぁぁ。(僕の場合は3分程度)

Hello World

こんにちは!!

/bin/bashを実行したら、コンテナ内でシェルが起動する

$ docker run -i -t centos /bin/bash
bash-4.1# exit
exit

たしかに。

参考

10
9
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
10
9