CentOS-Docker的安裝與使用

Get Docker Engine - Community for CentOS
參考:https://docs.docker.com/install/linux/docker-ce/centos/

1、Install using the repository

Before you install Docker Engine - Community for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.

(1) SET UP THE REPOSITORY

Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.

$ sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

Use the following command to set up the stable repository.

$ sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

(2) INSTALL DOCKER ENGINE - COMMUNITY

(a) Install the latest version of Docker Engine - Community and containerd, or go to the next step to install a specific version:

$ sudo yum install docker-ce docker-ce-cli containerd.io

If prompted to accept the GPG key, verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it.

(b) Start Docker.

$ sudo systemctl start docker

(c) Verify that Docker Engine - Community is installed correctly by running the hello-world image.

$ sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

Docker Engine - Community is installed and running. You need to use sudo to run Docker commands.

2恋追、Add the NVIDIA Container Toolkit

參考:https://github.com/NVIDIA/nvidia-docker
Note that with the release of Docker 19.03, usage of nvidia-docker2 packages are deprecated since NVIDIA GPUs are now natively supported as devices in the Docker runtime. If you are an existing user of the nvidia-docker2 packages, review the instructions in the “Upgrading with nvidia-docker2” section.

For first-time users of Docker 19.03 and GPUs, continue with the instructions for getting started below.

$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo

$ sudo yum install -y nvidia-container-toolkit
$ sudo systemctl restart docker

Usage

#### Test nvidia-smi with the latest official CUDA image
$ docker run --gpus all nvidia/cuda:9.0-base nvidia-smi

# Start a GPU enabled container on two GPUs
$ docker run --gpus 2 nvidia/cuda:9.0-base nvidia-smi

# Starting a GPU enabled container on specific GPUs
$ docker run --gpus '"device=1,2"' nvidia/cuda:9.0-base nvidia-smi
$ docker run --gpus '"device=UUID-ABCDEF,1"' nvidia/cuda:9.0-base nvidia-smi

# Specifying a capability (graphics, compute, ...) for my container
# Note this is rarely if ever used this way
$ docker run --gpus all,capabilities=utility nvidia/cuda:9.0-base nvidia-smi
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末悼凑,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子鸡捐,更是在濱河造成了極大的恐慌栈暇,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,427評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件箍镜,死亡現(xiàn)場離奇詭異源祈,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)色迂,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,551評論 3 395
  • 文/潘曉璐 我一進(jìn)店門香缺,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人歇僧,你說我怎么就攤上這事图张。” “怎么了诈悍?”我有些...
    開封第一講書人閱讀 165,747評論 0 356
  • 文/不壞的土叔 我叫張陵祸轮,是天一觀的道長。 經(jīng)常有香客問我侥钳,道長适袜,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,939評論 1 295
  • 正文 為了忘掉前任慕趴,我火速辦了婚禮痪蝇,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘冕房。我一直安慰自己躏啰,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,955評論 6 392
  • 文/花漫 我一把揭開白布耙册。 她就那樣靜靜地躺著给僵,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上帝际,一...
    開封第一講書人閱讀 51,737評論 1 305
  • 那天蔓同,我揣著相機(jī)與錄音,去河邊找鬼蹲诀。 笑死斑粱,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的脯爪。 我是一名探鬼主播则北,決...
    沈念sama閱讀 40,448評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼痕慢!你這毒婦竟也來了尚揣?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,352評論 0 276
  • 序言:老撾萬榮一對情侶失蹤掖举,失蹤者是張志新(化名)和其女友劉穎快骗,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體塔次,經(jīng)...
    沈念sama閱讀 45,834評論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡方篮,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,992評論 3 338
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了俺叭。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片恭取。...
    茶點(diǎn)故事閱讀 40,133評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖熄守,靈堂內(nèi)的尸體忽然破棺而出蜈垮,到底是詐尸還是另有隱情,我是刑警寧澤裕照,帶...
    沈念sama閱讀 35,815評論 5 346
  • 正文 年R本政府宣布攒发,位于F島的核電站,受9級特大地震影響晋南,放射性物質(zhì)發(fā)生泄漏惠猿。R本人自食惡果不足惜害驹,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,477評論 3 331
  • 文/蒙蒙 一胳赌、第九天 我趴在偏房一處隱蔽的房頂上張望匈睁。 院中可真熱鬧榔组,春花似錦、人聲如沸瘤袖。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,022評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽董虱。三九已至扼鞋,卻和暖如春申鱼,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背云头。 一陣腳步聲響...
    開封第一講書人閱讀 33,147評論 1 272
  • 我被黑心中介騙來泰國打工捐友, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人溃槐。 一個月前我還...
    沈念sama閱讀 48,398評論 3 373
  • 正文 我出身青樓匣砖,卻偏偏與公主長得像,于是被迫代替她去往敵國和親昏滴。 傳聞我的和親對象是個殘疾皇子脆粥,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,077評論 2 355

推薦閱讀更多精彩內(nèi)容