docker笔记

简介:Docker 容器技术。镜像 images;容器 container;仓库 repository 等,从安装到使用,入门教程

Docker简介

初认识

  1. build, ship, and run any app, anywhere
  2. 镜像,容器,仓库
  3. 集装箱,标准化,隔离

Docker架构

docker架构

镜像 images

  • 就是一个只读的模板,可以用来创建容器,可包含多个容器
  • 使用 unionfs(Union File System) 来实现文件管理

images

容器 container

  • 容器是从镜像中创建的运行实例,每个容器相互隔离

container

仓库 repository

  • 仓库(Repository)是集中存放镜像文件的场所

Centos 6.5 安装Docker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//1. 查看系统内核版本,需升级内核至3.x
uname -r
2.6.32-431.el6.x86_64

//2.下载yum源,然后升级系统内核
cd /etc/yum.repos.d/
wget http://www.hop5.in/yum/el6/hop5.repo
yum install kernel-ml-aufs kernel-mk-aufs-devel

//3.修改/etc/grub.conf中default=0
vim /etc/grub.conf

//4.重启
reboot

//5.安装docker
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum -y install docker-io

//6.修改/etc/sysconfig/selinux文件,将SELINUX的值设置为disabled。
vim /etc/sysconfig/selinux
service docker start
chkconfig docker on

//7.检查是否安装完成
docker version
reboot

Docker 使用命令

  1. docker images
  2. docker ps
  3. docker pull hello-world
  4. docker run -d
  5. docker exec -it xxx bash

私有镜像搭建