【docker】 centos上安装以及使用,以及遇到的几个问题

基本上是参考菜鸟教程的 http://www.runoob.com/docker/centos-docker-install.html

但是遇到些问题以及解决方案。

1. 安装, 命令

   yum install docker
   yum install -y yum-utils device-mapper-persistent-data lvm2
   yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
   yum makecache fast
   yum -y install docker-ce
   yum -y --skip-broken install docker-ce
   systemctl start docker
   systemctl status docker.service

 遇到问题: 在最后一步中, 启动docker service的时候,遇到问题如下

 failed at last: 
 ]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2019-05-22 17:52:36 CST; 19s ago
     Docs: http://docs.docker.com
  Process: 16597 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --defaul                                                  t-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --                                                  init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS                                                   $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
 Main PID: 16597 (code=exited, status=1/FAILURE)

May 22 17:52:35 host-10-76-24-68 systemd[1]: Starting Docker Application Container Engine...
May 22 17:52:35 host-10-76-24-68 dockerd-current[16597]: time="2019-05-22T17:52:35.251455113+08:00" level=warning msg="...und"
May 22 17:52:35 host-10-76-24-68 dockerd-current[16597]: time="2019-05-22T17:52:35.252939117+08:00" level=info msg="lib...606"
May 22 17:52:36 host-10-76-24-68 dockerd-current[16597]: time="2019-05-22T17:52:36.266268473+08:00" level=warning msg="over...
May 22 17:52:36 host-10-76-24-68 dockerd-current[16597]: Error starting daemon: SELinux is not supported with the overl...lse)
May 22 17:52:36 host-10-76-24-68 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
May 22 17:52:36 host-10-76-24-68 systemd[1]: Failed to start Docker Application Container Engine.
May 22 17:52:36 host-10-76-24-68 systemd[1]: Unit docker.service entered failed state.
May 22 17:52:36 host-10-76-24-68 systemd[1]: docker.service failed.

解决方案,修改配置docker配置文件,“/etc/sysconfig/docker”, 将selinux 给disable。

modify /etc/sysconfig/docker, 
 line "OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'"  to "OPTIONS='--selinux-enabled=false --log-driver=journald --signature-verification=false'
"
  then, run "systemctl start docker"

 

2. 启动 一个docker 容器,以“hello-world”作为实例

cmd: " docker run hello-world"

结果失败了,遇到问题如下(以下是问题的主要输出):

Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

解决方案  https://stackoverflow.com/questions/23111631/cannot-download-docker-images-behind-a-proxy

  1.  mkdir /etc/systemd/system/docker.service.d
  2. 将以下两行输入到/etc/systemd/system/docker.service.d/http-proxy.conf
      [Service]
      Environment="HTTP_PROXY=http://proxy.example.com:80/" 
  3.  重新加载数据
      systemctl daemon-reload
  4.  查看配置是否生效
      systemctl show --property Environment docker
  5.  重启docker 服务
      systemctl restart docker

3. 重新尝试执行 “ docker run hello-world”, 发现新的问题

]# 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
1b930d010525: Pull complete
Digest: sha256:0e11c388b664df8a27a901dce21eb89f11d8292f7fca1b3e3c4321bf7897bffe
Status: Downloaded newer image for docker.io/hello-world:latest
/usr/bin/docker-current: Error response from daemon: error creating overlay mount to /var/lib/docker/overlay2/c5fffa6bac4381ba4f52fb9df9740a3e205c4abf2c2b5f35e2f91e2e1317b1e5/merged: invalid argument.
See '/usr/bin/docker-current run --help'.

解决方案:https://www.centos.bz/2018/06/%E8%A7%A3%E5%86%B3-error-creating-overlay-mount-to-var-lib-docker-overlay2/

  systemctl stop docker   #停止docker服务
  rm -rf /var/lib/docker  #清理镜像
  vi /etc/sysconfig/docker-storage
   修改   DOCKER_STORAGE_OPTIONS="--storage-driver overlay"   #修改存储类型,把空的DOCKER_STORAGE_OPTIONS参数改为overlay:
  systemctl start docker  #启动docker应该就可以了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值