我将Telegraf作为Docker容器运行,其中包含docker-compose
文件。
telegraf:
image: telegraf:1.26.3
container_name: telegraf
depends_on:
socket-proxy:
condition: service_started
influxdb:
condition: service_healthy
hostname: telegraf
volumes:
# several volumes
ports:
# several ports
networks:
- socket
- data_export
restart: unless-stopped
labels:
<<: *default-labels
diun.include_tags: "^latest$$;^1.26.3$$"
它工作正常,但我添加了一些influxdb连接([[outputs.influxdb]]
),当容器启动时,会显示一个警告:
2023-06-10T14:25:16Z I! Found 14 secrets...
2023-06-10T14:25:16Z W! Insufficient lockable memory 64kb when 112kb is required. Please increase the limit for Telegraf in your Operating System!
我尝试在容器中执行ulimit
,但它不工作。
root@telegraf:/# ulimit -l
64
root@telegraf:/# ulimit -l 112
bash: ulimit: max locked memory: cannot modify limit: Operation not permitted
我试图在我的docker-compose
文件中添加ulimits
,但我得到一个panic错误
ulimits:
memlock: 112
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa0525f]
goroutine 1 [running]:
github.com/awnumar/memguard/core.Purge.func1(0xc0001df930)
/go/pkg/mod/github.com/awnumar/memguard@v0.22.3/core/exit.go:23 +0x3f
github.com/awnumar/memguard/core.Purge()
/go/pkg/mod/github.com/awnumar/memguard@v0.22.3/core/exit.go:51 +0x25
github.com/awnumar/memguard/core.Panic({0x5be2400, 0xc0002a2330})
/go/pkg/mod/github.com/awnumar/memguard@v0.22.3/core/exit.go:85 +0x25
github.com/awnumar/memguard/core.NewBuffer(0x20)
/go/pkg/mod/github.com/awnumar/memguard@v0.22.3/core/buffer.go:73 +0x2d5
github.com/awnumar/memguard/core.NewCoffer()
/go/pkg/mod/github.com/awnumar/memguard@v0.22.3/core/coffer.go:30 +0x34
github.com/awnumar/memguard/core.init.0()
/go/pkg/mod/github.com/awnumar/memguard@v0.22.3/core/enclave.go:15 +0x2e
如何增加此容器的最大锁定内存?
1条答案
按热度按时间ldxq2e6h1#
我不确定这一点,但我认为
memlock
值被解释为 bytes,因此要指定112 KB的限制,您需要编写:一个测试似乎证实了我的解释;给定这个完整的compose文件:
在我
docker-compose up
堆栈之后,我可以执行telegraf
容器并运行ulimit -a
,然后看到“锁定内存”ulimit显示为112
。