Docker 运行 openldap,报错:[Errno 17] 文件存在

Docker run the openldap,get the error:[Errno 17] File exists

我参考了官网的命令运行openldap容器。但我得到如下错误,有人可以提供帮助。困扰我很久了。我 运行 的命令是:

docker run --name xingyue_openldap --restart always  -v /data/openldap/data:/var/lib/ldap -v 

/data/openldap/slapd:/etc/ldap/slapd.d --env LDAP_ORGANISATION="xingyue" --env LDAP_DOMAIN="xingyue.com" \
--env LDAP_ADMIN_PASSWORD="admin" -e LDAP_TLS=false -p 389:389 -p 636:636 --detach osixia/openldap:1.3.0 --copy-service

像这样的错误并重复输出:

*** Killing all processes...
*** CONTAINER_LOG_LEVEL = 3 (info)
*** Copy /container/service to /container/run/service ignored
*** /container/run/service already exists
*** Search service in CONTAINER_SERVICE_DIR = /container/run/service :
*** link /container/run/service/:ssl-tools/startup.sh to /container/run/startup/:ssl-tools
*** failed to link /container/run/service/:ssl-tools/startup.sh to /container/run/startup/:ssl-tools: [Errno 17] File exists: '/container/run/service/:ssl-tools/startup.sh' -> '/container/run/startup/:ssl-tools'
*** link /container/run/service/slapd/startup.sh to /container/run/startup/slapd
*** failed to link /container/run/service/slapd/startup.sh to /container/run/startup/slapd: [Errno 17] File exists: '/container/run/service/slapd/startup.sh' -> '/container/run/startup/slapd'
*** link /container/run/service/slapd/process.sh to /container/run/process/slapd/run
*** directory /container/run/process/slapd already exists
*** failed to link /container/run/service/slapd/process.sh to /container/run/process/slapd/run : [Errno 17] File exists: '/container/run/service/slapd/process.sh' -> '/container/run/process/slapd/run'
*** Set environment for startup files
*** Environment files will be processed in this order : 
Caution: previously defined variables will not be overriden.
/container/environment/99-default/default.startup.yaml
/container/environment/99-default/default.yaml

To see how this files are processed and environment variables values,
run this container with '--loglevel debug'
*** Running /container/run/startup/:ssl-tools...
*** Running /container/run/startup/slapd...
Start OpenLDAP...
*** /container/run/startup/slapd failed with status 1
enter code here

我会说这里的问题与数据量有关,您可以使用以下命令启动 LDAP 服务器

mkdir ldap
cd ldap
mkdir data slapd
docker run --name xingyue_openldap --restart always  -v $PWD/data:/var/lib/ldap -v $PWD/slapd:/etc/ldap/slapd.d --env LDAP_ORGANISATION="xingyue" --env LDAP_DOMAIN="xingyue.com" \
--env LDAP_ADMIN_PASSWORD="admin" -e LDAP_TLS=false -p 389:389 -p 636:636 --detach osixia/openldap:1.3.0 --copy-service

或者您可以使用以下 docker-撰写文件

version: '3.7'

services:
  ldap_server:
    image: wshihadeh/ldap:withdata
    environment:
      LDAP_ADMIN_PASSWORD: test1234
      LDAP_BASE_DN: dc=shihadeh,dc=intern
    ports:
      - 389:389
    volumes:
      - ldap_data:/var/lib/ldap
      - ldap_config:/etc/ldap/slapd.d

  ldap_server_admin:
    image: osixia/phpldapadmin:0.7.2
    ports:
      - 8090:80
    environment:
      PHPLDAPADMIN_LDAP_HOSTS: ldap_server
      PHPLDAPADMIN_HTTPS: 'false'

volumes:
  ldap_data:
  ldap_config:

使用 docker-compose

启动 LDAP
docker-compose up -d

不知道为什么我的docker缺少docker0网卡,所以我重装docker0网卡,然后重启docker。这是错误的原因