LoginSignup
18
18

More than 5 years have passed since last update.

Docker入門: 1日目

Last updated at Posted at 2014-07-04

Docker?

Dockerとは?

こちらをご参照。

Dockerの運用

#04 作業の流れと用語を理解しよう - ドットインストール

MacでDockerを使ってDebian環境を作る

インストール

  1. こちらからDocker for OSX Instller(Boot2Docker-1.0.1.pkg)をダウンロード
  2. インストーラを起動し、Virtual BoxとDocker for OSXをインストール

初期化

  1. アプリケーションフォルダからboot2dockerを起動

または

$ boot2docker init
$ boot2docker start
$ export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375

Dockerの起動と停止

起動
$ boot2docker start
停止
$ boot2docker stop

Debianを動かす

  1. Docker Hub RegistryからDebianのイメージを検索
  2. Debianイメージをダウンロード
  3. Debianイメージからコンテナを作成

起動する。

$ docker start
2014/07/04 09:42:38 Waiting for VM to be started...
.......
2014/07/04 09:42:59 Started.
2014/07/04 09:42:59 Your DOCKER_HOST env variable is already set correctly.

$ 

イメージ、コンテナがまだなにもない状態。

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

$ 

Debianイメージをダウンロードする。

$ docker pull debian:latest
Pulling repository debian
63f650c4db34: Download complete 
511136ea3c5a: Download complete 
2e5f1fce06be: Download complete 

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
debian              latest              63f650c4db34        2 days ago          85.18 MB

$

コンテナを作り、コンソール上で起動する。

$ docker run -it debian /bin/bash
root@83a10b218035:/#

確認

Debianの中にいます。

root@83a10b218035:/# uname -a
Linux a680e2a7e30e 3.14.1-tinycore64 #1 SMP Mon Jun 2 04:19:19 UTC 2014 x86_64 GNU/Linux

root@83a10b218035:/# cat /etc/debian_version
7.5

root@83a10b218035:/# exit

Dockerの終了したプロセスを確認します。

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

$

続く

Docker入門: 2日目

参考

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