docker简介

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镜像平台)
相关文章
相关标签/搜索