Redis在Docker容器中无故关闭

时间:2018-09-11 00:27:17

标签: docker redis docker-compose amazon-ecs

我正在尝试使用docker-compose启动redis docker容器,但我总是收到此错误。这是我的docker-compose运行命令docker-compose -f docker-compose.yml builddocker-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...

1 个答案:

答案 0 :(得分:0)

遇到了同样的问题。经过一番挖掘,我们发现它由于不活动而被 systemd 杀死。 运行 systemctl show docker.service 命令显示 inactive 和 active enter 时间戳与 redis 服务停止和重新启动时匹配。

InactiveEnterTimestamp=Tue 2021-08-03 22:07:19 AEST
ActiveEnterTimestamp=Wed 2021-08-04 09:30:36 AEST

我们的解决方案只是在 redis 上执行一些活动,使其不会进入非活动状态。

相关问题