重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这篇文章主要介绍“Docker的简介与安装步骤”,在日常操作中,相信很多人在Docker的简介与安装步骤问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Docker的简介与安装步骤”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
创新互联主营南和网站建设的网络公司,主营网站建设方案,App定制开发,南和h5小程序设计搭建,南和网站营销推广欢迎南和等地区企业咨询
Docker是开源应用容器引擎,轻量级容器技术。
Docker可以让开发者打包他们的应用,依赖包及配置文件打包到一个轻量级,可移植的容器中,然后发布到任何流行的Linux系统上,也可以实现虚拟化。
容器完全使用沙箱技术,互相之间不会有任何接口。
类似于虚拟机技术(vmware,vitural),但docker直接运行再操作系统上,而不是运行再虚拟机中,速度块,,性能开销低。
Docker支持将软件编译成一个镜像,然后再镜像中把各种软件做好配置,将镜像发布出去,其他使用者可以直接使用这个镜像。运行中的这个镜像称为容器,容器启动时非常快速的。
Web应用的自动化打包和发布。
自动化测试和持续集成。
在服务型环境中部署和调整数据库或其他后台应用。
从头编译或扩展现有的OpenShift或Cloud Foundry平台来搭建自己的Paas环境。
Docker是C/S架构,客户端向守护进程发送请求,守护进程处理并返回给客户端。
Dcoekr Daemon为守护进程,后台运行,默认情况下,Docker Daemon只响应本地host的客户端请求,可以通过设置允许远程客户端请求。
一个只读模板,可以用来创建容器,一个镜像可以创建多个容器。
Docker提供了一个很简单的机制来创建和更新现有的镜像,甚至可以直接从其他人那里获取做好的镜像直接使用。
容器基于镜像来启动,可运行一个或多个应用。
Docker每个容器都是互相隔离的,保证安全。
仓库是集中存放镜像的场所,类似于git代码仓库等。
仓库和仓库注册服务区是有区别的。仓库注册服务器一般存放多个仓库,每个仓库又存放多个镜像,每个镜像又不同的标签。
仓库分为公有仓库和私有仓库。
最大的公有库为Docker Hub,国内有阿里云,daocloud等。
[root[@localhost](https://my.oschina.net/u/570656) ~]# cd /etc/yum.repos.d/ [root[@localhost](https://my.oschina.net/u/570656) yum.repos.d]# ls CentOS-Base.repo CentOS-Media.repo CentOS-CR.repo CentOS-Sources.repo CentOS-Debuginfo.repo CentOS-Vault.repo CentOS-fasttrack.repo [root[@localhost](https://my.oschina.net/u/570656) yum.repos.d]# vim Ali-docker.repo [Aliyun_docker] name=aliyun.com_docker baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/ enabled=1 gpgcheck=1 gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg [root[@localhost](https://my.oschina.net/u/570656) yum.repos.d]# yum -y install docker-ce [root[@localhost](https://my.oschina.net/u/570656) yum.repos.d]# systemctl start docker [root@localhost yum.repos.d]# docker version Client: Docker Engine - Community Version: 19.03.3 API version: 1.40 Go version: go1.12.10 Git commit: a872fc2f86 Built: Tue Oct 8 00:58:10 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.3 API version: 1.40 (minimum version 1.12) Go version: go1.12.10 Git commit: a872fc2f86 Built: Tue Oct 8 00:56:46 2019 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.6 GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc: Version: 1.0.0-rc8 GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f docker-init: Version: 0.18.0 GitCommit: fec3683
[root@localhost yum.repos.d]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io docker version >= 1.12 {"registry-mirrors": ["http://f1361db2.m.daocloud.io"]} Success. You need to restart docker to take effect: sudo systemctl restart docker [root@localhost yum.repos.d]# systemctl restart docker [root@localhost yum.repos.d]# docker info Client: Debug Mode: false Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 19.03.3 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: false Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 3.10.0-514.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 3.686GiB Name: localhost ID: KBZD:H3B4:ZFHE:KSPT:6IWI:QEVA:AFJV:EUR3:OJEB:HVJI:R5GW:GEZC Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ #Registry已经改变为daocloud。 Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Registry Mirrors: http://f1361db2.m.daocloud.io/ Live Restore Enabled: false [root@localhost yum.repos.d]# cat /etc/docker/daemon.json #可以通过这个文件来修改镜像源。 {"registry-mirrors": ["http://f1361db2.m.daocloud.io"]}
[root@localhost yum.repos.d]# docker pull httpd Using default tag: latest latest: Pulling from library/httpd Image docker.io/library/httpd:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/ b8f262c62ec6: Pull complete 2c31b9311798: Pull complete 7422a3cdf4e3: Pull complete 1919d4fbf9e1: Pull complete 60812fa1ab4c: Pull complete Digest: sha256:729508026fba8e00c15e2770f9eed52706b4065b68f29e4871222e22c3725bb7 Status: Downloaded newer image for httpd:latest docker.io/library/httpd:latest [root@localhost yum.repos.d]# docker pull centos Using default tag: latest latest: Pulling from library/centos Image docker.io/library/centos:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/ 729ec3a6ada3: Pull complete Digest: sha256:72942f390a71a1ecdebd4151c9bc4ff186fe8e480adcd7ddec84427118785482 Status: Downloaded newer image for centos:latest docker.io/library/centos:latest [root@localhost yum.repos.d]# docker pull busybox Using default tag: latest latest: Pulling from library/busybox Image docker.io/library/busybox:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/ 7c9d20b9b6cd: Pull complete Digest: sha256:be38efcd3a8289ff66e60c5652beed36968eeb856ae5d90f3cf02ea81e4a57da Status: Downloaded newer image for busybox:latest docker.io/library/busybox:latest [root@localhost yum.repos.d]# docker pull ubuntu Using default tag: latest latest: Pulling from library/ubuntu Image docker.io/library/ubuntu:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/ 5667fdb72017: Pull complete d83811f270d5: Pull complete ee671aafb583: Pull complete 7fc152dfb3a6: Pull complete Digest: sha256:ae7933206172662ff785dbf595a6f09e9d43858fa865725a9c51c589ed482901 Status: Downloaded newer image for ubuntu:latest docker.io/library/ubuntu:latest [root@localhost yum.repos.d]# docker pull registry:2 2: Pulling from library/registry Image docker.io/library/registry:2 uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/ c87736221ed0: Pull complete 1cc8e0bb44df: Pull complete 54d33bcb37f5: Pull complete e8afc091c171: Pull complete b4541f6d3db6: Pull complete Digest: sha256:b224aa2d9a6397e9102b0b887a3e92496eadd76872efb7595bed97f9b76d2056 Status: Downloaded newer image for registry:2 docker.io/library/registry:2 [root@localhost yum.repos.d]# docker pull progrium/consul Using default tag: latest latest: Pulling from progrium/consul Image docker.io/progrium/consul:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/ c862d82a67a2: Pull complete 0e7f3c08384e: Pull complete 0e221e32327a: Pull complete 09a952464e47: Pull complete 60a1b927414d: Pull complete 4c9f46b5ccce: Pull complete 417d86672aa4: Pull complete b0d47ad24447: Pull complete fd5300bd53f0: Pull complete a3ed95caeb02: Pull complete d023b445076e: Pull complete ba8851f89e33: Pull complete 5d1cefca2a28: Pull complete Digest: sha256:8cc8023462905929df9a79ff67ee435a36848ce7a10f18d6d0faba9306b97274 Status: Downloaded newer image for progrium/consul:latest docker.io/progrium/consul:latest [root@localhost yum.repos.d]# docker pull progrium/stress Using default tag: latest latest: Pulling from progrium/stress Image docker.io/progrium/stress:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/ a3ed95caeb02: Pull complete 871c32dbbb53: Pull complete dbe7819a64dd: Pull complete d14088925c6e: Pull complete 58026d51efe4: Pull complete 7d04a4fe1405: Pull complete 1775fca35fb6: Pull complete 5c319e267908: Pull complete Digest: sha256:e34d56d60f5caae79333cee395aae93b74791d50e3841986420d23c2ee4697bf Status: Downloaded newer image for progrium/stress:latest docker.io/progrium/stress:latest
[root@localhost yum.repos.d]# vim /usr/lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0 --containerd=/run/containerd/containerd.sock #添加:-H tcp://0.0.0.0 [root@localhost yum.repos.d]# systemctl daemon-reload [root@localhost yum.repos.d]# systemctl restart docker
[root@localhost yum.repos.d]# netstat -anput | grep docker tcp6 0 0 :::2375 :::* LISTEN 7211/dockerd [root@localhost yum.repos.d]# iptables -F #需要放行2375端口。 [root@localhost yum.repos.d]# iptables-save
[root@localhost ~]# systemctl start docker [root@localhost ~]# iptables -F [root@localhost ~]# iptables-save [root@localhost ~]# docker -H 被连接端ip options
到此,关于“Docker的简介与安装步骤”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!