1

当服务器主分区已满时,我挂载了一个new disk并将Docker 默认根路径更改为该磁盘。具体步骤如下

  1. systemctl stop docker.service使用命令停止 Docker 服务

  2. 数据迁移cp -r .var/lib/docker/* /mnt/data/docker

  3. 修改daemon.json配置文件

{
  "insecure-registries":["xxx.xxx.xxx.xxx:xxxx","xx.xxx.xxx.xx:xxx"],
  "live-restore": true,
  "data-root": "/mnt/data/docker"
}
  1. 通过以下方式重启 Docker 服务systemctl stop docker.service

docker images我可以通过和看到原始图像和容器信息docker ps -a

但是当我从命令行检查 Docker 状态时,我收到以下错误

root@xxxx:~# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2021-03-08 19:38:06 CST; 7s ago
     Docs: https://docs.docker.com
 Main PID: 12877 (dockerd)
    Tasks: 247
   CGroup: /system.slice/docker.service
           ├─ 4395 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 1990 -container-ip 172.24.0.8 -container-port 1883
           ├─ 4423 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 1888 -container-ip 172.19.0.2 -container-port 1883
           ├─ 4432 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 1923 -container-ip 172.28.0.2 -container-port 1883
           ├─ 4435 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 1856 -container-ip 192.168.192.2 -container-port 1883
           ├─ 4448 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 1683 -container-ip 192.168.176.8 -container-port 1883
           ├─ 4456 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 1855 -container-ip 192.168.160.2 -container-port 1883
           ├─ 4474 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 1988 -container-ip 172.20.0.2 -container-port 1883
           ├─ 4676 setup-resolver /var/run/docker/netns/3afca278ff2c 127.0.0.11:37870 127.0.0.11:34561
           ├─ 4695 /sbin/iptables --wait -L -n
           ├─12877 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           ├─13708 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8091 -container-ip 192.168.128.2 -container-port 8000
           ├─13720 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9002 -container-ip 172.31.0.3 -container-port 9000
           ├─13731 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8092 -container-ip 172.21.0.4 -container-port 8000
           ├─13742 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9003 -container-ip 172.20.0.4 -container-port 9000
           ├─13758 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8123 -container-ip 192.168.96.3 -container-port 8000
           ├─13770 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9001 -container-ip 192.168.32.2 -container-port 9000
           ├─15762 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8010 -container-ip 192.168.176.5 -container-port 8000
           ├─15787 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8099 -container-ip 172.24.0.7 -container-port 8000
           └─16000 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8000 -container-ip 192.168.0.6 -container-port 8000

**Mar 08 19:38:10 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T19:38:10.743123800+08:00" level=warning msg="xtables contention detected while running [-t nat -C DOCKER -p tcp -d 0/0 --dport 1923 -j DNAT --to-dest
Mar 08 19:38:11 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T19:38:11.747714065+08:00" level=warning msg="xtables contention detected while running [-t nat -C DOCKER -p tcp -d 0/0 --dport 1856 -j DNAT --to-dest
Mar 08 19:38:11 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T19:38:11.750899979+08:00" level=warning msg="xtables contention detected while running [-t filter -C DOCKER ! -i br-1a4306a45084 -o br-1a4306a45084 -
Mar 08 19:38:11 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T19:38:11.755768353+08:00" level=warning msg="xtables contention detected while running [-t filter -A DOCKER ! -i br-f46376a67c00 -o br-f46376a67c00 -
Mar 08 19:38:11 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T19:38:11.758681889+08:00" level=warning msg="xtables contention detected while running [-t nat -D DOCKER -p tcp -d 0/0 --dport 1888 -j DNAT --to-dest
Mar 08 19:38:11 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T19:38:11.884016359+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 08 19:38:13 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T19:38:13.418598834+08:00" level=error msg="Handler for GET /containers/4411367a4b654b8393ded8b4212d6945d84a07a108b3f05a6561d6f381277a04/json returned
Mar 08 19:38:13 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: http: superfluous response.WriteHeader call from github.com/docker/docker/api/server/httputils.WriteJSON (httputils_write_json.go:11)

但是好像过一会又消失了

root@xxx:~/harbor# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2021-03-08 19:38:06 CST; 25min ago
     Docs: https://docs.docker.com
 Main PID: 12877 (dockerd)
    Tasks: 188
   CGroup: /system.slice/docker.service
           ├─10836 /usr/bin/docker-proxy -proto tcp -host-ip 127.0.0.1 -host-port 1514 -container-ip 172.25.0.2 -container-port 10514
           ├─12877 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           ├─13708 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8091 -container-ip 192.168.128.2 -container-port 8000
           ├─13720 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9002 -container-ip 172.31.0.3 -container-port 9000
           ├─13731 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8092 -container-ip 172.21.0.4 -container-port 8000
           ├─13742 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9003 -container-ip 172.20.0.4 -container-port 9000
           ├─13758 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8123 -container-ip 192.168.96.3 -container-port 8000
           ├─13770 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9001 -container-ip 192.168.32.2 -container-port 9000
           ├─15762 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8010 -container-ip 192.168.176.5 -container-port 8000
           ├─15787 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8099 -container-ip 172.24.0.7 -container-port 8000
           └─16000 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8000 -container-ip 192.168.0.6 -container-port 8000

Mar 08 20:03:22 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T20:03:22.488572549+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 08 20:03:24 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T20:03:24.618043201+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 08 20:03:26 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T20:03:26.699891790+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 08 20:03:28 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T20:03:28.755718305+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 08 20:03:31 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T20:03:31.232132801+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 08 20:03:34 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T20:03:34.511822519+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 08 20:03:39 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T20:03:39.403540253+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 08 20:03:45 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T20:03:45.966994222+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 08 20:03:47 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T20:03:47.446758477+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
Mar 08 20:03:55 iZ8vb9yzkqg41jw8ev9zfmZ dockerd[12877]: time="2021-03-08T20:03:55.828274659+08:00" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
root@xxx:~/harbor#

当我尝试重新启动 Harbor 时,出现以下错误并导致与服务器的远程连接断开

[Step 4]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating redis      ...
Creating harbor-portal ...
Creating redis         ... error
Creating registry      ...
Creating harbor-db     ... error
Creating harbor-portal ... error
ERROR: for harbor-db  Cannot start service postgresql: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused

Creating registryctl   ... error

ERROR: for harbor-portal  Cannot start service portal: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused
Creating registry      ... error
ERROR: for registryctl  Cannot start service registryctl: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused

ERROR: for registry  Cannot start service registry: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused

ERROR: for postgresql  Cannot start service postgresql: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused

ERROR: for redis  Cannot start service redis: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused

ERROR: for portal  Cannot start service portal: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused

ERROR: for registryctl  Cannot start service registryctl: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused

ERROR: for registry  Cannot start service registry: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused
ERROR: Encountered errors while bringing up the project.

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Session stopped
    - Press <return> to exit tab
    - Press R to restart session
    - Press S to save terminal output to file

Harbor 的 docker-compose YAML如下图所示

root@iZ8vb9yzkqg41jw8ev9zfmZ:~/harbor# cat docker-compose.yml
version: '2.3'
services:
  log:
    image: goharbor/harbor-log:v1.10.2
    container_name: harbor-log
    restart: always
    dns_search: .
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - DAC_OVERRIDE
      - SETGID
      - SETUID
    volumes:
      - /var/log/harbor/:/var/log/docker/:z
      - type: bind
        source: ./common/config/log/logrotate.conf
        target: /etc/logrotate.d/logrotate.conf
      - type: bind
        source: ./common/config/log/rsyslog_docker.conf
        target: /etc/rsyslog.d/rsyslog_docker.conf
    ports:
      - 127.0.0.1:1514:10514
    networks:
      - harbor
  registry:
    image: goharbor/registry-photon:v1.10.2
    container_name: registry
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
    volumes:
      - /data/registry:/storage:z
      - ./common/config/registry/:/etc/registry/:z
      - type: bind
        source: /data/secret/registry/root.crt
        target: /etc/registry/root.crt
    networks:
      - harbor
    dns_search: .
    depends_on:
      - log
    logging:
      driver: "syslog"
      options:
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "registry"
  registryctl:
    image: goharbor/harbor-registryctl:v1.10.2
    container_name: registryctl
    env_file:
      - ./common/config/registryctl/env
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
    volumes:
      - /data/registry:/storage:z
      - ./common/config/registry/:/etc/registry/:z
      - type: bind
        source: ./common/config/registryctl/config.yml
        target: /etc/registryctl/config.yml
    networks:
      - harbor
    dns_search: .
    depends_on:
      - log
    logging:
      driver: "syslog"
      options:
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "registryctl"
  postgresql:
    image: goharbor/harbor-db:v1.10.2
    container_name: harbor-db
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - DAC_OVERRIDE
      - SETGID
      - SETUID
    volumes:
      - /data/database:/var/lib/postgresql/data:z
    networks:
      harbor:
    dns_search: .
    env_file:
      - ./common/config/db/env
    depends_on:
      - log
    logging:
      driver: "syslog"
      options:
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "postgresql"
  core:
    image: goharbor/harbor-core:v1.10.2
    container_name: harbor-core
    env_file:
      - ./common/config/core/env
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - SETGID
      - SETUID
    volumes:
      - /data/ca_download/:/etc/core/ca/:z
      - /data/psc/:/etc/core/token/:z
      - /data/:/data/:z
      - ./common/config/core/certificates/:/etc/core/certificates/:z
      - type: bind
        source: ./common/config/core/app.conf
        target: /etc/core/app.conf
      - type: bind
        source: /data/secret/core/private_key.pem
        target: /etc/core/private_key.pem
      - type: bind
        source: /data/secret/keys/secretkey
        target: /etc/core/key
    networks:
      harbor:
    dns_search: .
    depends_on:
      - log
      - registry
      - redis
      - postgresql
    logging:
      driver: "syslog"
      options:
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "core"
  portal:
    image: goharbor/harbor-portal:v1.10.2
    container_name: harbor-portal
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
      - NET_BIND_SERVICE
    networks:
      - harbor
    dns_search: .
    depends_on:
      - log
    logging:
      driver: "syslog"
      options:
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "portal"

  jobservice:
    image: goharbor/harbor-jobservice:v1.10.2
    container_name: harbor-jobservice
    env_file:
      - ./common/config/jobservice/env
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
    volumes:
      - /data/job_logs:/var/log/jobs:z
      - type: bind
        source: ./common/config/jobservice/config.yml
        target: /etc/jobservice/config.yml
    networks:
      - harbor
    dns_search: .
    depends_on:
      - core
    logging:
      driver: "syslog"
      options:
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "jobservice"
  redis:
    image: goharbor/redis-photon:v1.10.2
    container_name: redis
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
    volumes:
      - /data/redis:/var/lib/redis
    networks:
      harbor:
    dns_search: .
    depends_on:
      - log
    logging:
      driver: "syslog"
      options:
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "redis"
  proxy:
    image: goharbor/nginx-photon:v1.10.2
    container_name: nginx
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
      - NET_BIND_SERVICE
    volumes:
      - ./common/config/nginx:/etc/nginx:z
      - /data/secret/cert:/etc/cert:z
    networks:
      - harbor
    dns_search: .
    ports:
      - 80:8080
      - 1880:8443
    depends_on:
      - registry
      - core
      - portal
      - log
    logging:
      driver: "syslog"
      options:
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "proxy"
networks:
  harbor:
    external: false

我不知道是什么导致了这个错误,希望有人能帮助我,谢谢。

4

0 回答 0