docker
和虛擬機相似,能夠簡單看做是輕量級的虛擬機
Docker is the world’s leading software container platform. Developers use Docker to eliminate 「works on my machine」 problems when collaborating on code with co-workers. Operators use Docker to run and manage apps side-by-side in isolated containers to get better compute density. Enterprises use Docker to build agile software delivery pipelines to ship new features faster, more securely and with confidence for both Linux and Windows Server apps.
準備一臺虛擬機(centos7.3平臺)
1,ip靜態(關閉NetworkManager),而且要能上公網
2,主機名配置和綁定
# hostnamectl set-hostname --static docker.cluster.com
# vim /etc/hosts
172.16.2.10 docker.cluster.com
3,時間同步
4,關閉防火牆,selinux
5,配置yum (本地iso源和163源)
# vim /etc/yum.repos.d/openstack.repo --公網速度慢的話就能夠使用局域網內下載好的163源
[centos163]
name=centos163
baseurl=ftp://172.16.2.5/centos163
enabled=1
gpgcheck=0
第一步:安裝docker,並啓動docker服務
# yum install docker
# systemctl start docker
# systemctl status docker
# systemctl enable docker
# docker version
# docker info
第二步:
docker基本使用
# docker images --查看本地下載的image
REPOSITORY TAG IMAGE ID CREATED SIZE
# docker search centos7.3 --經過centos7.3去docker.io上查找相關的images
# docker pull docker.io/ymark/centos7.3 --經過pull命令下載images,後面的就是image的名稱(前提網速要好)
第三步:
images實例操做
1,下載learn/tutorial鏡像
# docker pull learn/tutorial
2,images中運行命令
# docker run learn/tutorial echo "hello word"
3,images中安裝ping命令
# docker run learn/tutorial apt-get install ping -y
4,查看容器id
# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7e9fee837d29 learn/tutorial "apt-get install ping" 6 seconds ago Exited (0) 1 seconds ago clever_curran
4,保存
# docker commit 7e9fee837d29 learn/ping
5,查看下載的和保存的
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
learn/ping latest e774cfcb55ef 4 seconds ago 139.5 MB
docker.io/learn/tutorial latest a7876479f1aa 4 years ago 128 MB
6,在保存的image中運行安裝的ping命令
# docker run learn/ping ping www.baidu.com
7,正在運行的image能夠查看
# docker ps --能夠查看正在運行的image
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
625bb7d129dc learn/ping "ping 127.0.0.1" 8 seconds ago Up 7 seconds reverent_kowalevski
8,能夠把本身保存的image上傳到官網(須要帳號)
# docker push learn/ping
第四步:
課後實驗:
若是網速不太好,那麼嘗試國內鏡像中心(網易,阿里,daocloud等)
# docker pull hub.c.163.com/library/mysql:latest
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hub.c.163.com/library/mysql latest 9e64176cd8a2 9 weeks ago 407.1 MB
----------------------------------------------------
Kubernetes (k8s)
開源容器平臺 (能夠本身搭建docker鏡像平臺)