docker - Redis 在 docker 容器中无故关闭
问题描述
我正在尝试使用 docker-compose 启动一个 redis docker 容器,但我总是收到此错误。这是我的 docker-compose 运行命令docker-compose -f docker-compose.yml build
和docker-compose -f docker-compose.yml up -d --force-recreate
. 我在 aws ecs 上运行 docker 容器并使用 t2.micro ec2 实例。我不确定这是否是原因。任何见解都会有所帮助。
我还包括了我的 docker-compose.yml
version: '2.1'
services:
redis:
image: redis:latest
container_name: redis
volumes:
- redis_data:/data
ports:
- 6379:6379
app:
image: custom_image
build: .
depends_on:
redis:
condition: service_started
ports:
- 8003:8003
links:
- redis
volumes:
redis_data:
错误
1:C 11 Sep 00:18:34.345 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 11 Sep 00:18:34.348 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 11 Sep 00:18:34.348 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 11 Sep 00:18:34.349 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
1:M 11 Sep 00:18:34.349 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
1:M 11 Sep 00:18:34.349 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
1:M 11 Sep 00:18:34.350 * Running mode=standalone, port=6379.
1:M 11 Sep 00:18:34.350 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 11 Sep 00:18:34.350 # Server initialized
1:M 11 Sep 00:18:34.350 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 11 Sep 00:18:34.350 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
1:M 11 Sep 00:18:34.350 * Ready to accept connections
1:signal-handler (1536625117) Received SIGTERM scheduling shutdown...
1:M 11 Sep 00:18:37.375 # User requested shutdown...
1:M 11 Sep 00:18:37.375 * Saving the final RDB snapshot before exiting.
1:M 11 Sep 00:18:37.378 * DB saved on disk
1:M 11 Sep 00:18:37.378 # Redis is now ready to exit, bye bye...
解决方案
遇到同样的问题。经过一番挖掘,我们发现它由于不活动而被 systemd 杀死。运行systemctl show docker.service
命令显示不活动和活动的进入时间戳与redis服务停止和重新启动的时间相匹配。
InactiveEnterTimestamp=Tue 2021-08-03 22:07:19 AEST
ActiveEnterTimestamp=Wed 2021-08-04 09:30:36 AEST
我们的解决方案只是在 redis 上执行一些活动,使其不会进入非活动状态。
推荐阅读
- c++ - 如何在 Gstreamer 中检索属性名称
- linux - 在 GPR 文件中传递多个链接库
- php - 删除 PHP 手动触发错误消息的最后一部分
- vba - Set doc = IE.document 返回自动化错误
- reactjs - React:在本地和 redux 状态更新上附加组件动画
- sql-server - 用于在 SQL Server 中查找所有出现的模式的正则表达式
- c# - 如何使用 Aspose.Words in.Net 重复(循环)在现有模板中的表中插入书签和书签值
- java - 获取 NoSuchMethodError:org.hamcrest.core.StringContains.containsStringIgnoringCase
- xslt - 选择属性的特定部分并将其分配给变量
- jsonschema - JsonSchema:如何确保对象需要一个/特定属性?