大网数据广告活动
服务器运维问答

Cannot build a working docker image for an openldap service

· 52CE 我爱测

I'm new to docker and I'm doing a little bit of experimenting with it. I was trying to create a docker image for an openldap service. I tried creating the image starting from debian:latest image provided from the official docker …

问题原文

原帖链接 · Giorgio Mossa · CC BY-SA 4.0

I'm new to docker and I'm doing a little bit of experimenting with it.

I was trying to create a docker image for an openldap service. I tried creating the image starting from debian:latest image provided from the official docker repos.

This is the content of my Dockerfile

FROM debian
RUN DEBIAN_FRONTEND="noninteractive" apt-get update
RUN DEBIAN_FRONTEND="noninteractive" apt-get install --yes --no-install-recommends slapd ldap-utils
RUN apt-get clean

I tried to create a container based on this image with

docker container run --interactive --tty --name=prova image

here image is the name of the image build from the Dockerfile above. When I try to run slapd with service slapd start I get the following error:

[614.896012] Out of memory: Killed process 4005 (slapd) total-vm: 795276KB, anon-rss:334664KB, file-rss:8KB, shmem-rss:0kB, UID:101, pgtables:1108kB, oom_score_adj:0 

So it seems to be a kernel error, due to explosion of the process inside the memory, though I cannot understand what causes it, the same ldap service works fine in the host system or in kvm virtual machines I created.
I've also tried to install openldap inside a live container created from the debian:latest image, I get the same error.

So here's my question: can anyone explain what is going on here and what it's causing the error? Thanks for your help.

已采纳解答

原帖链接 · Otto · CC BY-SA 4.0

Running service slapd start inside a docker container will probably waste some resources, in you case memory, since it needs to run the initd and some shell processes, thus triggering oom-killer quicker than single process container.

You can check the Dockerfile from a well used openldap docker image [1], which runs slapd process directly.

If you are preparing an image for production use, you should also think about Backups and TLS, which are supported by osixia/docker-openldap [1] and docker-openldap-backup [2]

[1] https://github.com/osixia/docker-openldap

[2] https://github.com/osixia/docker-openldap-backup

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-01-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。