欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2016年10月05日 18:31:08   投稿:mdxy-dxy  
這篇文章主要介紹了在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軟件庫

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

# 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軟件庫的配置之后,安裝也變得異常的簡(jiǎn)單,只需要以下一句即可:

# yum install docker-engine

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

# service docker start

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

使用以下命令:

# docker run hello-world

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

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

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'.

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

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ū):

service docker start

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

docker是需要使用root權(quán)限運(yùn)行的,但仍然可以通過創(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 容器:

[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)。若要斷開與容器的連接,輸入 exit。

[root@cd05639b3f5c /]# cat /etc/RedHat-release
CentOSLinux release 7.0.1406(Core)
[root@cd05639b3f5c /]#exit
exit
[root@localhost ~]#

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

[root@localhost ~]# docker search ubuntu
[root@localhost ~]# docker search fedora

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

相關(guān)文章

  • 如何解決mysql配置文件錯(cuò)誤導(dǎo)致在docker中無法啟動(dòng)的問題

    如何解決mysql配置文件錯(cuò)誤導(dǎo)致在docker中無法啟動(dòng)的問題

    這篇文章主要介紹了如何解決mysql配置文件錯(cuò)誤導(dǎo)致在docker中無法啟動(dòng)的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • 如何使用docker創(chuàng)建minio鏡像并上傳文件并提供demo

    如何使用docker創(chuàng)建minio鏡像并上傳文件并提供demo

    這篇文章主要介紹了使用docker創(chuàng)建minio鏡像并上傳文件,提供demo,minio還是很方便的,從部署到使用,都可以非??焖俚拇罱?而且比較穩(wěn)定,需要的朋友可以參考下
    2023-09-09
  • 在wsl-ubuntu中如何通過 docker 啟動(dòng) gpu-jupyter

    在wsl-ubuntu中如何通過 docker 啟動(dòng) gpu-jupyter

    這篇文章主要介紹了在wsl-ubuntu中如何通過 docker 啟動(dòng) gpu-jupyter,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2024-01-01
  • Docker掛載資料卷保存MySQL數(shù)據(jù)

    Docker掛載資料卷保存MySQL數(shù)據(jù)

    這篇文章介紹了Docker掛載資料卷保存MySQL數(shù)據(jù)的方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-01-01
  • Docker容器中文件與本地相互復(fù)制拷貝方式

    Docker容器中文件與本地相互復(fù)制拷貝方式

    這篇文章主要介紹了Docker容器中文件與本地相互復(fù)制拷貝方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • docker一鍵安裝wordpress的方法步驟

    docker一鍵安裝wordpress的方法步驟

    這篇文章主要介紹了docker一鍵安裝wordpress的方法步驟,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-07-07
  • 使用Docker搭建Redis主從復(fù)制的集群

    使用Docker搭建Redis主從復(fù)制的集群

    這篇文章主要介紹了使用Docker搭建Redis主從復(fù)制的集群,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-07-07
  • Docker 教程之鏡像創(chuàng)建及修改詳細(xì)介紹

    Docker 教程之鏡像創(chuàng)建及修改詳細(xì)介紹

    這篇文章主要介紹了Docker 教程之鏡像創(chuàng)建及修改詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下
    2016-12-12
  • Docker安裝Nginx教程實(shí)現(xiàn)圖例講解

    Docker安裝Nginx教程實(shí)現(xiàn)圖例講解

    這篇文章主要介紹了Docker安裝Nginx教程圖例講解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-09-09
  • 如何通過Jenkins定期清理為None的鏡像詳解

    如何通過Jenkins定期清理為None的鏡像詳解

    這篇文章主要給大家介紹了關(guān)于如何通過Jenkins定期清理為None的鏡像的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-11-11

最新評(píng)論