docker安装记录

1、安装

按照官网的命令执行了一圈

dnf -y install dnf-plugins-core

dnf config-manager \
>     --add-repo \
>     https://download.docker.com/linux/fedora/docker-ce.repo

dnf config-manager --set-enabled docker-ce-test

dnf install docker-ce docker-ce-cli containerd.io

dnf list docker-ce  --showduplicates | sort -r

dnf -y install docker-ce-3:19.03.0-3.fc31 containerd.io

systemctl start docker

结果提示:

Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.

 

试了下journalctl -xe

[root@localhost qiuzhenfei]# journalctl -xe
-- 
-- docker.service 单元已结束停止操作。
12月 01 21:39:26 localhost.localdomain systemd[1]: docker.socket: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- The unit docker.socket has successfully entered the 'dead' state.
12月 01 21:39:26 localhost.localdomain systemd[1]: Closed Docker Socket for the API.
-- Subject: docker.socket 单元已结束停止操作
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- docker.socket 单元已结束停止操作。
12月 01 21:39:26 localhost.localdomain systemd[1]: Stopping Docker Socket for the API.
-- Subject: docker.socket 单元已开始停止操作
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- docker.socket 单元已开始停止操作。
12月 01 21:39:26 localhost.localdomain systemd[1]: Starting Docker Socket for the API.
-- Subject: docker.socket 单元已开始启动
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- docker.socket 单元已开始启动。
12月 01 21:39:26 localhost.localdomain systemd[1]: Listening on Docker Socket for the API.
-- Subject: docker.socket 单元已结束启动
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- docker.socket 单元已结束启动。
-- 
-- 启动结果为“done”。
12月 01 21:39:26 localhost.localdomain systemd[1]: docker.service: Start request repeated too quickly.
12月 01 21:39:26 localhost.localdomain systemd[1]: docker.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- The unit docker.service has entered the 'failed' state with result 'exit-code'.
12月 01 21:39:26 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: docker.service 单元已失败
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- docker.service 单元已失败。
-- 
-- 结果为“failed”。
12月 01 21:39:26 localhost.localdomain systemd[1]: docker.socket: Failed with result 'service-start-limit-hit'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- The unit docker.socket has entered the 'failed' state with result 'service-start-limit-hit'.
 

根据网上的说法,需要将/etc/docker/daemon.json改为/etc/docker/daemon.conf

改了之后发现还是不行报错:12月 01 21:50:28 localhost.localdomain dockerd[3236]: failed to start daemon: Devices cgroup isn't mounted

继续百度,发现如果采用binary docker的使用方式
https://github.com/docker/docker/blob/master/docs/installation/binaries.md
你会发现docker启动,报错Devices cgroup isn't mounted
这个是因为默认的cgroup的cpu,memory等没有被挂载,需要使用一个脚本来挂载:


#!/bin/sh
# Copyright 2011 Canonical, Inc
#           2014 Tianon Gravi
# Author: Serge Hallyn
#         Tianon Gravi
set -e

# for simplicity this script provides no flexibility

# if cgroup is mounted by fstab, don't run
# don't get too smart - bail on any uncommented entry with 'cgroup' in it
if grep -v '^#' /etc/fstab | grep -q cgroup; then
                echo 'cgroups mounted from fstab, not mounting /sys/fs/cgroup'
                        exit 0
fi

# kernel provides cgroups?
if [ ! -e /proc/cgroups ]; then
                exit 0
fi

# if we don't even have the directory we need, something else must be wrong
if [ ! -d /sys/fs/cgroup ]; then
                exit 0
fi

# mount /sys/fs/cgroup if not already done
if ! mountpoint -q /sys/fs/cgroup; then
                mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
fi

cd /sys/fs/cgroup

# get/mount list of enabled cgroup controllers
for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
                mkdir -p $sys
                        if ! mountpoint -q $sys; then
                                                if ! mount -n -t cgroup -o $sys cgroup $sys; then
                                                                                rmdir $sys || true
                                                                                                fi
                                                                                                        fi
                                                                                                done

                                                                                                # example /proc/cgroups:
                                                                                                #  #subsys_name hierarchy       num_cgroups     enabled
                                                                                                #  cpuset       2       3       1
                                                                                                #  cpu  3       3       1
                                                                                                #  cpuacct      4       3       1
                                                                                                #  memory       5       3       0
                                                                                                #  devices      6       3       1
                                                                                                #  freezer      7       3       1
                                                                                                #  blkio        8       3       1

                                                                                                exit 0
 

 

 

最终问题解决

环境:

fedora31

 

你可能感兴趣的:(Java)