Uninstall old versions
Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.
$ 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
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. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
执行上面的步骤,失败了。
然后直接用 yum install -y docker
Start Docker.
$ sudo systemctl start docker
Docker Hub上有大量的高质量的镜像可以用,
image右侧还有docker拉取命令;
镜像加速
首先下载文件:
wget http://oyh1cogl9.bkt.clouddn.com/setmirror.sh
然后执行命令:
sh setmirror.sh https://registry-mirror.qiniu.com
[root@localhost ~]# sh setmirror.sh https://registry-mirror.qiniu.com
Linux distribution: CentOS 7.2.1511
Docker version: 1.13.1
1.13.1
Configuring --registry-mirror=https://registry-mirror.qiniu.com for your docker install.
{"registry-mirrors": ["https://registry-mirror.qiniu.com"],}
Success. You need to restart docker to take effect: sudo systemctl restart docker
[root@localhost ~]#
到这里,镜像加速已经安装成功了,
重启docker
[root@localhost ~]# 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 Sun 2018-07-15 17:03:16 EDT; 13s ago
Docs: http://docs.docker.com
Process: 5636 ExecStart=/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 --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: 5636 (code=exited, status=1/FAILURE)
Jul 15 17:03:16 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Jul 15 17:03:16 localhost.localdomain dockerd-current[5636]: unable to configure the Docker daemon with fil...ing
Jul 15 17:03:16 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status...LURE
Jul 15 17:03:16 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Jul 15 17:03:16 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Jul 15 17:03:16 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
重启失败了;
查看问题
[root@localhost ~]# systemctl status docker -l
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2018-07-15 17:03:58 EDT; 19s ago
Docs: http://docs.docker.com
Process: 5749 ExecStart=/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 --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: 5749 (code=exited, status=1/FAILURE)
Jul 15 17:03:58 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Jul 15 17:03:58 localhost.localdomain dockerd-current[5749]: unable to configure the Docker daemon with file /etc/docker/daemon.json: invalid character '}' looking for beginning of object key string
Jul 15 17:03:58 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Jul 15 17:03:58 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Jul 15 17:03:58 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Jul 15 17:03:58 localhost.localdomain systemd[1]: docker.service failed.
[root@localhost ~]#
修改问题文件
vi /etc/docker/daemon.json
[root@localhost ~]# vi /etc/docker/daemon.json
{"registry-mirrors": ["https://registry-mirror.qiniu.com"],}
发现这里多了一个逗号,删除之。在重启
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2018-07-15 17:05:27 EDT; 6s ago
Docs: http://docs.docker.com
Main PID: 5810 (dockerd-current)
Memory: 13.1M
CGroup: /system.slice/docker.service
├─5810 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current -...
└─5814 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd...
Jul 15 17:05:26 localhost.localdomain dockerd-current[5810]: time="2018-07-15T17:05:26.936150050-04:00" lev...nd"
Jul 15 17:05:26 localhost.localdomain dockerd-current[5810]: time="2018-07-15T17:05:26.936327761-04:00" lev...t."
Jul 15 17:05:26 localhost.localdomain dockerd-current[5810]: time="2018-07-15T17:05:26.946308436-04:00" lev...ue"
Jul 15 17:05:27 localhost.localdomain dockerd-current[5810]: time="2018-07-15T17:05:27.190880241-04:00" lev...ss"
Jul 15 17:05:27 localhost.localdomain dockerd-current[5810]: time="2018-07-15T17:05:27.284272925-04:00" lev...e."
Jul 15 17:05:27 localhost.localdomain dockerd-current[5810]: time="2018-07-15T17:05:27.285541195-04:00" lev...ix"
Jul 15 17:05:27 localhost.localdomain dockerd-current[5810]: time="2018-07-15T17:05:27.291587537-04:00" lev...on"
Jul 15 17:05:27 localhost.localdomain dockerd-current[5810]: time="2018-07-15T17:05:27.291609233-04:00" lev...3.1
Jul 15 17:05:27 localhost.localdomain dockerd-current[5810]: time="2018-07-15T17:05:27.305132514-04:00" lev...ck"
Jul 15 17:05:27 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#
over
网友评论