rhel 下docker的安裝配置與使用
阿新 • • 發佈:2019-02-07
docker的簡介
Docker 是一個開源的應用容器引擎,讓開發者可以打包他們的應用以及依賴包到一個可移植的容器中,然後釋出到任何流行的 Linux 機器上,也可以實現虛擬化。容器是完全使用沙箱機制,相互之間不會有任何介面。
docker的安裝
首先我們需要配置好docker的yum源,保證自己的主機可以上網。
vim /etc/yum.repos.d/docker.repo
配置如下:
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/cent
enabled=1
gpgcheck=0
gpgkey=https://yum.dockerproject.org/gpg
然後重新整理一下yum源
yum clean all && yum repolist
安裝之前確認好核心的版本至少為3.10以上,可以使用uname -r來檢視。
準備好以後可以直接使用yum安裝
yum install docker-engine
啟動docker的服務
service docker start
可以將docker設定為開機自啟動.
chkconfig docker on
docker的簡單配置
檢查docker的版本
docker version
可以看到
Client:
Version: 17.05.0-ce
API version: 1.29
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:06:25 2017
OS/Arch: linux/amd64
Server:
Version: 17.05.0-ce
API version: 1.29 (minimum version 1.12)
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:06:25 2017
OS/Arch: linux/amd64
Experimental: false
搜尋可以使用的docker映象
docker search tutorial #假設尋找的映象名字為tutorial
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
learn/tutorial 28
georgeyord/reactjs-tutorial This is the backend of the React comment b... 4 [OK]
egamas/docker-tutorial Funny manpages 2 [OK]
mhausenblas/kairosdb-tutorial GitHub fetcher for KairosDB tutorial 1 [OK]
mjansche/tts-tutorial Software for a Text-to-Speech tutorial 1 [OK]
trausch/tutorial-delly Cancer Genomics Tutorial of Delly 1 [OK]
kidikarus/concourse-tutorial-47-tasks 0
chris24walsh/flask-aws-tutorial Runs a simple flask webapp demo, with the ... 0 [OK]
lukasheinrich/quickana-tutorial Image for the analysis code built from htt... 0
activeeon/par-connector-tutorial Do the par-connector tutorial with R. The ... 0 [OK]
paddledev/paddle-tutorial images that paddle tutorials use. 0
schwamster/docker-tutorial 0
camphor/python-tutorial camphor-/python-tutorial 0 [OK]
paulcos11/docker-tutorial docker tutorial 0 [OK]
kobe25/docker-tutorial Docker Tutorial 0 [OK]
onekit/rest-tutorial REST API server-side tutorial. How to do i... 0 [OK]
jbalexandre/docker-tutorial 0
biopython/biopython-tutorial Biopython with Tutorial running on top of ... 0 [OK]
imiell/git-101-tutorial 0
michelesr/docker-tutorial Docker Tutorial 0 [OK]
intrig/tutorial 0
starkandwayne/concourse-tutorial 0
starkandwayne/concourse-tutorial-ci 0
cloudboost/tutorial 0
lmcluck/tutorial online tutorial example 0
使用pull來下載映象
docker pull learn/tutorial
Using default tag: latest
latest: Pulling from learn/tutorial
271134aeb542: Already exists
Digest: sha256:2933b82e7c2a72ad8ea89d58af5d1472e35dacd5b7233577483f58ff8f9338bd
Status: Image is up to date for learn/tutorial:latest
在docker中測試
測試echo命令
docker run learn/tutorial echo "hello docker"
結果如下
hello docker
測試ls命令
docker run learn/tutorial ls
結果如下
bin
boot
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
selinux
srv
sys
tmp
usr
var