kstyrc / embedded-redis

Redis embedded server for Java integration testing
832 stars 366 forks source link

Not able to start embedded redis in a docker container #105

Open msarun opened 5 years ago

msarun commented 5 years ago

Able to start in memory redis on my mac, when i run the same build inside a docker container to start my tests, the tests fail connecting to redis.

sabya1979 commented 5 years ago

I am also getting same issue java.lang.IllegalStateException Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException Caused by: org.springframework.beans.factory.BeanCreationException Caused by: redis.embedded.exceptions.EmbeddedRedisException Caused by: java.io.IOException Caused by: java.io.IOException

DennisVetterAnchormen commented 4 years ago

Might be a little late, but I had the same error and found the cause, so I thought I might as well add a comment here. The issue seems to be, that the linux redis binaries shipped with the project were linked against glibc. This means, that it is not working on Alpine Linux (which many containers run on), because they use another implementation of the C standard library.

Changing my base image from alpine to debian / ubuntu solved the issue for me.

kyucumber commented 3 years ago
bash-4.4# uname -a
Linux 490bc54ba0f4 4.14.214-160.339.amzn2.x86_64 #1 SMP Sun Jan 10 05:53:05 UTC 2021 x86_64 Linux

bash-4.4# ls -al

-rwxr-xr-x    1 root     root       4311368 Mar 29 20:35 redis-server-3.0.7
-rwxr-xr-x    1 root     root        927664 Mar 29 20:35 redis-server-3.0.7-darwin

bash-4.4# ./redis-server-3.0.7
bash: ./redis-server-3.0.7: No such file or directory

It doesn't work alpine

$ uname -a
Linux d715755895b4 4.19.121-linuxkit #1 SMP Tue Dec 1 17:50:32 UTC 2020 x86_64 GNU/Linux

$ ./redis-server-3.0.7
1301:C 29 Mar 12:57:47.329 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server-3.0.7 /path/to/redis.conf
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 3.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1301
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'
breun commented 3 years ago

It also seems this project is not maintained anymore, but musl-based binaries of Redis exist on Alpine:

~ % docker run -it --rm alpine
/ # apk add redis
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/1) Installing redis (6.0.11-r0)
Executing redis-6.0.11-r0.pre-install
Executing redis-6.0.11-r0.post-install
Executing busybox-1.32.1-r6.trigger
OK: 8 MiB in 15 packages
/ # redis-
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli        redis-sentinel   redis-server

But embedded-redis probably doesn't detect whether the OS uses glibc or musl as its C standard library, and the included binary only works on glibc.

Another solution would be not use embedded-redis, but run Redis in a separate Docker container.