docker學習1:CentOS Docker 安裝
參考:
CentOS Docker 安裝
Docker支援以下的CentOS版本:
CentOS 7 (64-bit)
CentOS 6.5 (64-bit) 或更高的版本
前提條件
目前,CentOS 僅發行版本中的核心支援 Docker。
Docker 執行在 CentOS 7 上,要求系統為64位、系統核心版本為 3.10 以上。
Docker 執行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系統為64位、系統核心版本為 2.6.32-431 或者更高版本。
使用 yum 安裝(CentOS 7下)
Docker 要求 CentOS 系統的核心版本高於 3.10 ,檢視本頁面的前提條件來驗證你的CentOS 版本是否支援 Docker 。
透過 uname -r 命令檢視你當前的核心版本
[root@huixuan ~]# uname -a
Linux huixuan 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@huixuan ~]#
安裝 Docker
Docker 軟體包和依賴包已經包含在預設的 CentOS-Extras 軟體源裡,安裝命令如下:
啟動 Docker 後臺服務
service docker start
之後需要修改:Docker0網橋預設網段
[root@huixuan ~]# ps -ef | grep docker
root 3691 1 0 17:28 ? 00:00:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --seccomp-profile=/etc/docker/seccomp.json --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2
root 3698 3691 0 17:28 ? 00:00:00 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc --runtime-args --systemd-cgroup=true
root 3838 3817 0 17:30 pts/0 00:00:00 grep --color=auto docker
[root@huixuan ~]#
測試執行 hello-world
[root@huixuan ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for docker.io/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.
(amd64)
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 ID:
For more examples and ideas, visit:
[root@huixuan ~]#
使用指令碼安裝 Docker
1、使用 sudo 或 root 許可權登入 Centos。
2、確保 yum 包更新到最新。
yum update
3、執行 Docker 安裝指令碼。
[root@huixuan ~]# curl -fsSL | sh
# Executing docker install script, commit: 36b78b2
Warning: the "docker" command appears to already exist on this system.
If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.
執行這個指令碼會新增 docker.repo 源並安裝 Docker。
4、啟動 Docker 程式。
[root@huixuan ~]# service docker start
Redirecting to /bin/systemctl start docker.service
5、驗證 docker 是否安裝成功並在容器中執行一個測試的映象。
[root@huixuan ~]# docker run hello-world
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.
(amd64)
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 ID:
For more examples and ideas, visit:
[root@huixuan ~]#
到此,docker 在 CentOS 系統的安裝完成。
映象加速
鑑於國內網路問題,後續拉取 Docker 映象十分緩慢,我們可以需要配置加速器來解決,我使用的是網易的映象地址:。
新版的 Docker 使用 /etc/docker/daemon.json(Linux) 或者 %programdata%\docker\config\daemon.json(Windows) 來配置 Daemon。
請在該配置檔案中加入(沒有該檔案的話,請先建一個):
[root@huixuan ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": [""]
"bip":"192.168.100.1/24"
}
[root@huixuan ~]#
CentOS Docker 安裝
Docker支援以下的CentOS版本:
CentOS 7 (64-bit)
CentOS 6.5 (64-bit) 或更高的版本
前提條件
目前,CentOS 僅發行版本中的核心支援 Docker。
Docker 執行在 CentOS 7 上,要求系統為64位、系統核心版本為 3.10 以上。
Docker 執行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系統為64位、系統核心版本為 2.6.32-431 或者更高版本。
使用 yum 安裝(CentOS 7下)
Docker 要求 CentOS 系統的核心版本高於 3.10 ,檢視本頁面的前提條件來驗證你的CentOS 版本是否支援 Docker 。
透過 uname -r 命令檢視你當前的核心版本
[root@huixuan ~]# uname -a
Linux huixuan 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@huixuan ~]#
安裝 Docker
Docker 軟體包和依賴包已經包含在預設的 CentOS-Extras 軟體源裡,安裝命令如下:
啟動 Docker 後臺服務
service docker start
之後需要修改:Docker0網橋預設網段
[root@huixuan ~]# ps -ef | grep docker
root 3691 1 0 17:28 ? 00:00:00 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --seccomp-profile=/etc/docker/seccomp.json --selinux-enabled --log-driver=journald --signature-verification=false --storage-driver overlay2
root 3698 3691 0 17:28 ? 00:00:00 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc --runtime-args --systemd-cgroup=true
root 3838 3817 0 17:30 pts/0 00:00:00 grep --color=auto docker
[root@huixuan ~]#
測試執行 hello-world
[root@huixuan ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for docker.io/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.
(amd64)
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 ID:
For more examples and ideas, visit:
[root@huixuan ~]#
使用指令碼安裝 Docker
1、使用 sudo 或 root 許可權登入 Centos。
2、確保 yum 包更新到最新。
yum update
3、執行 Docker 安裝指令碼。
[root@huixuan ~]# curl -fsSL | sh
# Executing docker install script, commit: 36b78b2
Warning: the "docker" command appears to already exist on this system.
If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.
執行這個指令碼會新增 docker.repo 源並安裝 Docker。
4、啟動 Docker 程式。
[root@huixuan ~]# service docker start
Redirecting to /bin/systemctl start docker.service
5、驗證 docker 是否安裝成功並在容器中執行一個測試的映象。
[root@huixuan ~]# docker run hello-world
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.
(amd64)
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 ID:
For more examples and ideas, visit:
[root@huixuan ~]#
到此,docker 在 CentOS 系統的安裝完成。
映象加速
鑑於國內網路問題,後續拉取 Docker 映象十分緩慢,我們可以需要配置加速器來解決,我使用的是網易的映象地址:。
新版的 Docker 使用 /etc/docker/daemon.json(Linux) 或者 %programdata%\docker\config\daemon.json(Windows) 來配置 Daemon。
請在該配置檔案中加入(沒有該檔案的話,請先建一個):
[root@huixuan ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": [""]
"bip":"192.168.100.1/24"
}
[root@huixuan ~]#
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/312079/viewspace-2153570/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Docker學習(1)安裝Docker
- CentOS學習筆記 – 6. docker安裝CentOS筆記Docker
- docker 學習之一:docker 安裝Docker
- docker學習6:Docker 安裝 NginxDockerNginx
- docker學習7:Docker 安裝 PHPDockerPHP
- CentOS Docker 安裝CentOSDocker
- CentOS 安裝 dockerCentOSDocker
- CentOS安裝DockerCentOSDocker
- Docker學習(二)- Docker 安裝 JenkinsDockerJenkins
- Docker教程之四CentOS安裝DockerDockerCentOS
- docker 安裝與學習Docker
- centos下安裝dockerCentOSDocker
- centos 線上安裝 dockerCentOSDocker
- CentOS 8.4安裝DockerCentOSDocker
- Docker Centos安裝OpensshDockerCentOS
- Centos 7 Docker 安裝CentOSDocker
- Centos 安裝 Docker|教程CentOSDocker
- Centos 7 安裝 Docker 與 Docker ComposeCentOSDocker
- CentOS7 安裝 dockerCentOSDocker
- centos 下docker映象安裝CentOSDocker
- 在CentOS上安裝dockerCentOSDocker
- centOS(同redhat)安裝 dockerCentOSRedhatDocker
- 76-CentOS Docker 安裝CentOSDocker
- centos7安裝dockerCentOSDocker
- Centos6.5 Docker安裝CentOSDocker
- Docker centos 安裝syslogDockerCentOS
- Centos7.9 安裝 DockerCentOSDocker
- CentOS系統安裝dockerCentOSDocker
- CentOS7 docker docker-Composer 安裝CentOSDocker
- Centos7.9安裝Docker和Docker composeCentOSDocker
- Centos Docker安裝、升級、解除安裝CentOSDocker
- Centos7安裝安裝部署dockerCentOSDocker
- Centos7.9安裝解除安裝DockerCentOSDocker
- Docker 入門學習筆記一:Ubuntu安裝 DockerDocker筆記Ubuntu
- 使用Docker安裝Redis - 學習三DockerRedis
- Docker安裝(學習筆記一)Docker筆記
- 1、安裝docker引擎Docker
- Linux CentOS 安裝 docker 和 docker-composeLinuxCentOSDocker