1
1

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チュートリアル

Last updated at Posted at 2019-04-28

Dockerとは

Dockerは、仮想マシンを構築するためのもの。
Dockerの特徴は以下の3点

  • OS依存が少なく、導入が楽
  • コンテナ型のため、移植性が高く本番環境への移行もスムーズに行える。
  • ゲストOSがないため軽量になる(間違えっていたら教えてください)。

従来の仮想マシンの構築イメージ
image.png

Dockerの仮想マシン構築イメージ
image.png

インストール

こちらからインストールすることができる。
各自のOSにあったものをダウンロードしてください。
アカウントを作成する必要があります。
インストールがうまくいったかの確認
以下のようなものが出てくれば、うまくインストール出来ています

$ docker --version

Docker version 18.09.2, build 6247962

webサーバーを立てる&終了

初回起動はローカルにイメージがなく、公式からpullしているので起動に5秒ほどかかります。
2回目からはローカルに保存したイメージを使用する為、高速な起動が可能になります。

$ docker run -d -p 8080:80 --name webserver nginx

コンテナがきちんとできているか確認する

$ docker ps
# 以下のような表示がされる
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS             
5b8b3dccc4cd        nginx               "nginx -g 'daemon of…"   About a minute ago   Up About a minute  

コンテナを終了したい場合は

# CONTAINER IDでkill
$ docker kill 5b8b3dccc4cd 
or
# NAMESでkill
$ docker kill webserver

コンテナの削除

$ docker rm c5e7400c19c9
or
$ docker rm webserver
1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?