您好,登錄后才能下訂單哦!
這篇文章主要介紹“Docker的簡介與安裝步驟”,在日常操作中,相信很多人在Docker的簡介與安裝步驟問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Docker的簡介與安裝步驟”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
Docker是開源應(yīng)用容器引擎,輕量級容器技術(shù)。
Docker可以讓開發(fā)者打包他們的應(yīng)用,依賴包及配置文件打包到一個(gè)輕量級,可移植的容器中,然后發(fā)布到任何流行的Linux系統(tǒng)上,也可以實(shí)現(xiàn)虛擬化。
容器完全使用沙箱技術(shù),互相之間不會(huì)有任何接口。
類似于虛擬機(jī)技術(shù)(vmware,vitural),但docker直接運(yùn)行再操作系統(tǒng)上,而不是運(yùn)行再虛擬機(jī)中,速度塊,,性能開銷低。
??Docker支持將軟件編譯成一個(gè)鏡像,然后再鏡像中把各種軟件做好配置,將鏡像發(fā)布出去,其他使用者可以直接使用這個(gè)鏡像。運(yùn)行中的這個(gè)鏡像稱為容器,容器啟動(dòng)時(shí)非??焖俚?。
Web應(yīng)用的自動(dòng)化打包和發(fā)布。
自動(dòng)化測試和持續(xù)集成。
在服務(wù)型環(huán)境中部署和調(diào)整數(shù)據(jù)庫或其他后臺(tái)應(yīng)用。
從頭編譯或擴(kuò)展現(xiàn)有的OpenShift或Cloud Foundry平臺(tái)來搭建自己的Paas環(huán)境。
??Docker是C/S架構(gòu),客戶端向守護(hù)進(jìn)程發(fā)送請求,守護(hù)進(jìn)程處理并返回給客戶端。
??Dcoekr Daemon為守護(hù)進(jìn)程,后臺(tái)運(yùn)行,默認(rèn)情況下,Docker Daemon只響應(yīng)本地host的客戶端請求,可以通過設(shè)置允許遠(yuǎn)程客戶端請求。
一個(gè)只讀模板,可以用來創(chuàng)建容器,一個(gè)鏡像可以創(chuàng)建多個(gè)容器。
Docker提供了一個(gè)很簡單的機(jī)制來創(chuàng)建和更新現(xiàn)有的鏡像,甚至可以直接從其他人那里獲取做好的鏡像直接使用。
容器基于鏡像來啟動(dòng),可運(yùn)行一個(gè)或多個(gè)應(yīng)用。
Docker每個(gè)容器都是互相隔離的,保證安全。
倉庫是集中存放鏡像的場所,類似于git代碼倉庫等。
倉庫和倉庫注冊服務(wù)區(qū)是有區(qū)別的。倉庫注冊服務(wù)器一般存放多個(gè)倉庫,每個(gè)倉庫又存放多個(gè)鏡像,每個(gè)鏡像又不同的標(biāo)簽。
倉庫分為公有倉庫和私有倉庫。
最大的公有庫為Docker Hub,國內(nèi)有阿里云,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已經(jīng)改變?yōu)閐aocloud。 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 #可以通過這個(gè)文件來修改鏡像源。 {"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
到此,關(guān)于“Docker的簡介與安裝步驟”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。