您好,登錄后才能下訂單哦!
這篇文章主要介紹“Docker的簡介與安裝步驟”,在日常操作中,相信很多人在Docker的簡介與安裝步驟問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Docker的簡介與安裝步驟”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
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的簡介與安裝步驟”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。