Docker安装配置教程
之前docker很久就写了笔记了。后⾯因为家⾥有事,耽搁了⼀年。 现在把这部分笔记重新上传⼀下。⼤家看看。
Docker要求:
lunix内核,要求3.8以上
centos7
Docker是⼀个进程,⼀启动就两个进程,⼀个服务,⼀个守护进程。占⽤资源就⾮常少,启动速度⾮常快,1s。
⼀台机器上vm,3到10个实例。docker 100到10000。
1.核⼼概念:
1)镜像images,事先做好⼀些基础功能(软件),可以在镜像上在来安装新的内容。
2)容器container
3)数据卷volume,把数据映射到linux磁盘⽬录,业务把数据写⼊这个⽬录,容器重新启动时,⾃⼰加载数据卷,数据⼜恢复了。有问题的。(争论,数据库这种⽅式需求适不适合docker)
4)仓库repository,maven仓库概念⼀样
2.java
类(只读) 镜像(只读,不允许修改)
对象(写临时的内容) 容器,在镜像基础上允许⽤户写数据,临时数据
docker
部署后台系统,
虚拟机linux安装jdk1)linux Centos7
2)安装jdk
3)安装tomcat
4)部署war包
5)启动tomcat,设置端⼝,访问
docker可以产⽣基础镜像,每加⼀层新的内容也形成新的镜像。每个镜像都可以去在加新的内容。变化⽆穷,复⽤资源。
加载虚拟机的vm镜像,先不要打开。
然后,设置好虚拟机软件的vm。
NAT模式查询⽹关配置,上⽹(注意,设置请根据⾃⼰的ip信息进⾏设置。⽬的是为了保持⽹关、⼦⽹掩码⼀致,ip地址⽹段⼀致,ip地址不⼀样)
设置OK后,使⽤其使设置⽣效。
重载⼀下⽹络配置
centos7 命令发⽣巨⼤变化
p addr #查看IP地址 ip add
service network restart #重启⽹络
systemctl restart network.service #重启⽹络centos7
vi /etc/hosts #127.0.0.1 dredis
hostname dreids #注意必须修改机器名hostname
ping www.baidu #如果出现baidu的ip地址则表⽰⽹络连通
1.1.1安装Docker
1.1.1.1第⼀步:安装⼯具包
$ sudo yum install -y yum-utils #安装⼯具包,缺少这些依赖将⽆法完成
执⾏结果:
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
epel | 4.3 kB 00:00:00
extras | 3.4 kB 00:00:00
update | 3.4 kB 00:00:00
(1/3): epel/7/x86_64/updateinfo | 797 kB 00:00:00
(2/3): epel/7/x86_64/primary_db | 4.7 MB 00:00:00
(3/3): update/7/x86_64/primary_db | 4.8 MB 00:00:00
Loading mirror speeds from cached hostfile
Package yum-utils-1.1.arch already installed and latest version
Nothing to do
1.1.1.2第⼆步:设置远程仓库
$sudo yum-config-manager --add-repo download.docker/linux/po
执⾏结果:
Loaded plugins: fastestmirror, langpacks
adding repo from: download.docker/linux/po
grabbing file download.docker/linux/po to /pos.po
repo saved to /pos.po
1.1.1.3第三步:安装
$ sudo yum install docker-ce
执⾏结果:
Loaded plugins: fastestmirror, langpacks
docker-ce-stable | 2.9 kB 00:00:00
docker-ce-stable/x86_64/primary_db | 4.8 kB 00:00:00
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:17.-s will be installed
--> Processing Dependency: docker-ce-selinux >= 17.-s for package: docker-ce-17.-s.x86_64 --> Processing Dependency: libcgroup for package: docker-ce-17.-s.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-ce-17.-s.x86_64
-
-> Running transaction check
---> arch 0:17.-s will be installed
--> Processing Dependency: policycoreutils-python for package: docker-ce-selinux-17.-s.noarch
--> Processing Dependency: policycoreutils-python for package: docker-ce-selinux-17.-s.noarch
---> Package libcgroup.x86_64 0:0.41-11.el7 will be installed
---> Package libseccomp.x86_64 0:2.3.1-2.el7 will be installed
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-11.el7_3 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-1 for package: policycoreutils-python-2.5-11.el7_3.x86_64
-
-> Processing Dependency: libsemanage-python >= 2.5-5 for package: policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.6.5-3.el7_3.1 will be installed
---> Package checkpolicy.x86_64 0:2.5-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-5.1.el7_3 will be installed
---> arch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-1.1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================
Package Arch Version Repository Size
===================================================================================================================== Installing:
docker-ce x86_64 17.-s docker-ce-stable 19 M
Installing for dependencies:
audit-libs-python x86_64 2.6.5-3.el7_3.1 update 70 k
checkpolicy x86_64 2.5-4.el7 base 290 k
docker-ce-selinux noarch 17.-s docker-ce-stable 28 k
libcgroup x86_64 0.41-11.el7 base 65 k
libseccomp x86_64 2.3.1-2.el7 base 56 k
libsemanage-python x86_64 2.5-5.1.el7_3 update 104 k
policycoreutils-python x86_64 2.5-11.el7_3 update 445 k
python-IPy noarch 0.75-6.el7 base 32 k
setools-libs x86_64 3.3.8-1.1.el7 base 612 k
Transaction Summary
===================================================================================================================== Install 1 Package (+9 Dependent packages)
Total download size: 20 M
Installed size: 24 M
Is this ok [y/d/N]: y
Downloading packages:
(1/10): audit-libs-python-2.6.5-3.el7_3.1.x86_64.rpm | 70 kB 00:00:00
(2/10): checkpolicy-2.5-4.el7.x86_64.rpm | 290 kB 00:00:00
(3/10): libseccomp-2.3.1-2.el7.x86_64.rpm | 56 kB 00:00:00
(4/10): libcgroup-0.41-11.el7.x86_64.rpm | 65 kB 00:00:00
(5/10): policycoreutils-python-2.5-11.el7_3.x86_64.rpm | 445 kB 00:00:00
(6/10): setools-libs-3.3.8-1.1.el7.x86_64.rpm | 612 kB 00:00:00
(7/10): libsemanage-python-2.5-5.1.el7_3.x86_64.rpm | 104 kB 00:00:00
(8/10): python-IPy-0.arch.rpm | 32 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-selinux-17.-s.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-selinux-17.-s.noarch.rpm is not installed
(9/10): docker-ce-selinux-17.-s.noarch.rpm | 28 kB 00:00:00
(10/10): docker-ce-17.-s.x86_64.rpm | 19 MB 00:00:00
---------------------------------------------------------------------------------------------------------------------
Total 23 MB/s | 20 MB 00:00:00
Retrieving key from download.docker/linux/centos/gpg
Importing GPG key 0x621E9F35:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论