一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

云服務(wù)器|WEB服務(wù)器|FTP服務(wù)器|郵件服務(wù)器|虛擬主機(jī)|服務(wù)器安全|DNS服務(wù)器|服務(wù)器知識(shí)|Nginx|IIS|Tomcat|

服務(wù)器之家 - 服務(wù)器技術(shù) - 服務(wù)器知識(shí) - 在CentOS 7上安裝Docker環(huán)境的方法與注意事項(xiàng)

在CentOS 7上安裝Docker環(huán)境的方法與注意事項(xiàng)

2020-09-25 20:46服務(wù)器之家 服務(wù)器知識(shí)

這篇文章主要介紹了在CentOS 7上安裝Docker環(huán)境的方法與注意事項(xiàng),需要的朋友可以參考下

官網(wǎng)文檔:https://docs.docker.com/engine/installation/linux/centos/ ,本文大部分是照搬官方文檔寫的,如果你英文還不錯(cuò),那么就直接移步官方文檔吧,如果你英文實(shí)在是不行,那就勉強(qiáng)看一下本人這生澀的翻譯~

以下操作均在root用戶下完成

docker的安裝要求64位系統(tǒng)且內(nèi)核版本大于3.10。所以如果是centos的話,必須安裝CentOS7.0或以上版本。
我們這里使用的是CentOS7.2 mininul。

uname -r
3.10.0-327.28.3.el7.x86_64

安裝docker前執(zhí)行一下全系統(tǒng)的軟件版本升級(jí):
yum -y update

1.配置yum軟件庫(kù)

為保證安裝的成功,首先使用yum update更新Yum包,表示我的好多yum包都需要更新,1500+的包,如果你像我一樣好久沒(méi)有更新過(guò),那就耐心等候吧。
然后在yum軟件庫(kù)中新增docker的配置:

?
1
2
3
4
5
6
7
8
# tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

2.安裝Docker

有了yum軟件庫(kù)的配置之后,安裝也變得異常的簡(jiǎn)單,只需要以下一句即可:

# yum install docker-engine

3.啟動(dòng)Docker
一切就緒之后,使用start命令來(lái)啟動(dòng)Docker守護(hù)進(jìn)程:

# service docker start

4.輸出hello-world
程序員貌似跟hello-world有仇,有事兒沒(méi)事就打印人家一下,玩docker咱們當(dāng)前也不例外,先來(lái)個(gè)hello-world吧,這里的基本原理是利用人家已經(jīng)寫好的hello-world鏡像,下載到本地,然后把他運(yùn)行起來(lái)~

使用以下命令:

# docker run hello-world

然后控制端會(huì)輸出類似于如下的信息,就證明我們的docker環(huán)境安裝成功了~

在CentOS 7上安裝Docker環(huán)境的方法與注意事項(xiàng)

在這里,我第一次失敗了~顯示:

?
1
2
3
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fhello-world%3Apull&service=registry.docker.io: net/http: TLS handshake timeout.
See 'docker run --help'.

然后我又來(lái)了一次就好了,應(yīng)該是墻的原因吧,看著是網(wǎng)絡(luò)訪問(wèn)失敗了~

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest
 
Hello from Docker!
This message shows that your installation appears to be working correctly.
 
To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
  executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
  to your terminal.
 
To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash
 
Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com
 
For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

設(shè)置為自啟動(dòng):

chkconfig docker on

調(diào)整docker數(shù)據(jù)目錄:

把一個(gè)獨(dú)立的數(shù)據(jù)分區(qū)設(shè)置為docker數(shù)據(jù)目錄,需手工把docker原目錄的數(shù)據(jù)都移到新的存儲(chǔ)分區(qū)上去,然后以新的存儲(chǔ)分區(qū)掛載到/var/lib/docker目錄下。

service docker stop

拷數(shù)據(jù)及掛分區(qū):

在CentOS 7上安裝Docker環(huán)境的方法與注意事項(xiàng)

service docker start

4、創(chuàng)建一個(gè)專用的docker group

docker是需要使用root權(quán)限運(yùn)行的,但仍然可以通過(guò)創(chuàng)建一個(gè)專用的用戶組的方式,讓一個(gè)具備sudo權(quán)限的普通用戶管理docker服務(wù)。

 

復(fù)制代碼 代碼如下:

# groupadd docker
# usermod -aG docker bjxtb

 

退出當(dāng)前會(huì)話,重新登錄后使用bjxtb直接管理docker:

$ docker run hello-world

運(yùn)行一個(gè) Docker 容器:

?
1
2
[root@localhost ~]# docker run -i -t centos /bin/bash
[root@dbf66395436d /]#

我們可以看到,CentOS 容器已經(jīng)被啟動(dòng),并且我們得到了 bash 提示符。在 docker 命令中我們使用了 “-i 捕獲標(biāo)準(zhǔn)輸入輸出”和 “-t 分配一個(gè)終端或控制臺(tái)”選項(xiàng)。若要斷開(kāi)與容器的連接,輸入 exit。

?
1
2
3
4
5
[root@cd05639b3f5c /]# cat /etc/RedHat-release
CentOSLinux release 7.0.1406(Core)
[root@cd05639b3f5c /]#exit
exit
[root@localhost ~]#

我們還可以搜索基于 Fedora 和 Ubuntu 操作系統(tǒng)的容器。

?
1
2
[root@localhost ~]# docker search ubuntu
[root@localhost ~]# docker search fedora

顯示當(dāng)前正在運(yùn)行容器的列表

在CentOS 7上安裝Docker環(huán)境的方法與注意事項(xiàng)

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 成人欧美一区二区三区 | 草草视频免费看 | 午夜精品久久久久久久99蜜桃i | 免费观看在线观看 | 免费在线观看a | 色cccwww在线播放 | 欧美贵妇vs高跟办公室 | 国产精品毛片无码 | 久久永久免费视频 | 欧洲vodafonewifi日本 | 成人精品一级毛片 | 吉川爱美与黑人解禁 | 女bbbbxxxx视频 | 好男人在线观看免费高清2019韩剧 | 九九国产在线视频 | 奇米777四色精品综合影院 | 久久亚洲国产成人影院 | 成人欧美一区二区三区黑人 | 视频二区 素人 制服 国产 | 青草久久精品亚洲综合专区 | brazzers欧美教师 | 国产精品一区二区三区久久 | 午夜欧美精品久久久久久久 | 亚洲日本中文字幕天堂网 | 欧美亚洲国产综合在线 | 亚洲精品在线免费观看视频 | 国产成人免费片在线视频观看 | 国产成人精品高清不卡在线 | 欧美黑人换爱交换乱理伦片 | 男人狂躁女人gif动态图 | 99国产在线视频 | 色欲都市 | 无耻之徒第十一季在线观看 | 天堂久久久久va久久久久 | 深夜免费看 | 国产chinese男同gay | 精品国产一区二区三区久 | 精品亚洲国产一区二区 | 亚洲性爱区 | 韩国黄色片网站 | 狠狠干奇米 |