1. 程式人生 > >5.docker的疑難雜癥

5.docker的疑難雜癥

odata problem ril ipy exec time epo 表示 rac

根據官方文檔:https://docs.docker.com/install/linux/docker-ce/centos/搭建docker
1.卸載docker舊版本:

sudo yum remove docker                   docker-client                   docker-client-latest                   docker-common                   docker-latest                   docker-latest-logrotate                   docker
-logrotate docker-selinux docker-engine-selinux docker-engine\

2.安裝相關工具類:

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

3.配置docker倉庫:

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

會報以下錯誤:
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
Could not fetch/save url https://download.docker.com/linux/centos/docker-ce.repo to file /etc/yum.repos.d/docker-ce.repo
: [Errno 14] curl#35 - "TCP connection reset by peer

這是由於國內訪問不到docker官方鏡像的緣故
可以通過aliyun的源來完成:

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

出現以下內容則表示docker倉庫配置成功:
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

4.安裝docker

sudo yum install docker-ce

出現以下異常:
Loaded plugins: fastestmirror
base
https://download-stage.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer"
Trying other mirror.
 One of the configured repositories failed (Docker CE Stable - x86_64),
 and yum doesn‘t have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=docker-ce-stable ...

     4. Disable the repository permanently, so yum won‘t use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable docker-ce-stable
        or
            subscription-manager repos --disable=docker-ce-stable

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=docker-ce-stable.skip_if_unavailable=true

failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.
https://download-stage.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer"

分析原因為:阿裏的鏡像庫文件也指向docker官方庫,所以需要修改庫文件

sudo vim /etc/yum.repos.d/docker-ce.repo

通過命令把https://download-stage.docker.com替換為http://mirrors.aliyun.com/docker-ce

命令如下::%s#https://download-stage.docker.com#http://mirrors.aliyun.com/docker-ce#g

在執行安裝docker的部分媽可安裝成功。

sudo yum install docker-ce

內容如下:

Installed:
  docker-ce.x86_64 0:18.03.0.ce-1.el7.centos

Dependency Installed:
  audit-libs-python.x86_64 0:2.7.6-3.el7 checkpolicy.x86_64 0:2.5-4.el7   container-selinux.noarch 2:2.42-1.gitad8f0f7.el7 libcgroup.x86_64 0
  libtool-ltdl.x86_64 0:2.4.2-22.el7_3   pigz.x86_64 0:2.3.3-1.el7.centos policycoreutils-python.x86_64 0:2.5-17.1.el7     python-IPy.noarch

Complete!

5.驗證docker安裝成功:

啟動docker:
sudo systemctl start docker

驗證docker:

sudo docker run hello-world

則會出現以下異常:

Unable to find image ‘hello-world:latest‘ locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pulling fs layer
docker: error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/registry-v2/docker/registry/v2/blobs/sha256/e3/e38bc07ac18e
See ‘docker run --help‘.

此錯誤也是網絡問題:國內無法訪問dockerhub
配置阿裏雲的docker鏡像庫:在阿裏雲開通容器鏡像服務拿到加速地址在執行以下命令:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-EOF
{
  "registry-mirrors": ["https://{自已的編碼}.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

再次驗證docker:

sudo docker run hello-world

出現以下內容則表示安裝成功:

Unable to find image ‘hello-world:latest‘ locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
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.
    (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:
 https://hub.docker.com/

For more examples and ideas, visit:

-------------------------------------------------------------------------------------------------------------------
如何用docker做滲透測試呢
具體看這個網站
https://getpass.cn/2018/03/14/Use%20Docker%20to%20build%20a%20variety%20of%20loopholes%20(my%20mother%20no%20longer%20has%20to%20worry%20about%20not%20having%20practiced%20in%20the%20shooting%20range)/
或者這個
http://vulapps.evalbug.com/

 

5.docker的疑難雜癥