进入代码构建;目前希望在本地 ubuntu 映像上使用 redis;
使用以下脚本:
version: 0.2
phases:
install:
commands:
- apt update
- apt install -y redis-server wget
pre_build:
commands:
- wget https://raw.githubusercontent.com/Hronom/wait-for-redis/master/wait-for-redis.sh
- chmod +x ./wait-for-redis.sh
- service redis-server start
- ./wait-for-redis.sh localhost:6379
build:
commands:
- redis-cli info
- redis-cli info server
目前在我们看来,docker-compose 最终不是必需的,我们首先会考虑以这种方式使用它 - 期待标准的 ubuntu 行为。
我们正在用类似的方法安装 postgres,它确实可以正常启动并且完全可用。
在这里,我们无法正确启动 redis,等待 redis 不断重试(不断收到错误Could not connect to Redis at localhost:6379: Connection refused
(
使用 ec2 Linux 映像(基于 yum(,我们没有这样的问题
在那个 ubuntu 上下文中启动 redis 的正确方法是什么?
刚刚遇到了同样的问题。
当我向构建规范添加cat /var/log/redis/*.log
时,我发现 Redis 无法绑定:
Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address
进一步的研究表明,这是一个已知的问题:https://github.com/redis/redis/issues/3241
。这可以通过在构建规范中添加这些行来修复(在使用 Redis 之前(:
- sed -i '/^bind/s/bind.*/bind 127.0.0.1/' /etc/redis/redis.conf
- service redis-server restart