0

in Ubuntu 20.04 I created a Linux Container that I called "ubuntuone", with Ubuntu 20.04 as well.

In the Linux Container I installed Redis, but I get Could not connect to Redis at 127.0.0.1:6379

(base) raphy@pc:~$ lxc exec ubuntuone -- /bin/bash
root@ubuntuone:~# redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> 

This is the output of ifconfig in the linux container:

(base) raphy@pc:~$ lxc exec ubuntuone -- /bin/bash
root@ubuntuone:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.65.116.195  netmask 255.255.255.0  broadcast 10.65.116.255
        inet6 fe80::216:3eff:fe5b:de10  prefixlen 64  scopeid 0x20<link>
        inet6 fd42:2159:3d69:bcae:216:3eff:fe5b:de10  prefixlen 64  scopeid 
0x0<global>
        ether 00:16:3e:5b:de:10  txqueuelen 1000  (Ethernet)
        RX packets 2004  bytes 903491 (903.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2419  bytes 1053136 (1.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8  bytes 496 (496.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 496 (496.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

I also tried to set in /etc/redis/redis.conf :

bind 10.65.116.195 ::1

but I get the same error

Update 1)

redis-server is installed but redis-service.service daemon has some problem:

root@ubuntuone:~# systemctl status redis-server.service
● redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; 
enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2021-07-28 
08:41:03 UTC; 3min 54s ago
       Docs: http://redis.io/documentation,
             man:redis-server(1)
   Main PID: 2640 (code=exited, status=1/FAILURE)
     Status: "Redis is loading..."

Jul 28 08:41:03 ubuntuone systemd[1]: Starting Advanced key-value 
store...
Jul 28 08:41:03 ubuntuone systemd[1]: redis-server.service: Main 
process exited, code=exited, status=1/FAILURE
Jul 28 08:41:03 ubuntuone systemd[1]: redis-server.service:    
Failed with result 'exit-code'.
Jul 28 08:41:03 ubuntuone systemd[1]: Failed to start Advanced 
key-value store.



root@ubuntuone:~# journalctl -xe
-- Subject: A start job for unit redis-server.service has begun 
execution
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit redis-server.service has begun execution.
-- 
-- The job identifier is 2538.
Jul 28 08:41:03 ubuntuone systemd[1]: redis-server.service: Main    
process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- An ExecStart= process belonging to unit redis-server.service 
has exited.
-- 
-- The process' exit code is 'exited' and its exit status is 1.
Jul 28 08:41:03 ubuntuone systemd[1]: redis-server.service:   
Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The unit redis-server.service has entered the 'failed' state 
with result 'exit-code'.
Jul 28 08:41:03 ubuntuone systemd[1]: Failed to start Advanced 
key-value store.
-- Subject: A start job for unit redis-server.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit redis-server.service has finished with a 
failure.
-- 
-- The job identifier is 2538 and the job result is failed.
Jul 28 08:44:39 ubuntuone systemd[1]: Reloading.
Jul 28 08:44:39 ubuntuone systemd[1]: systemd-udevd.service:     
Attaching egress BPF program to cgroup /sys/fs/cgro>
Jul 28 08:44:39 ubuntuone systemd[1]: systemd-journald.service:    
Attaching egress BPF program to cgroup /sys/fs/c>
Jul 28 08:44:39 ubuntuone systemd[1]: systemd-logind.service:     
Attaching egress BPF program to cgroup /sys/fs/cgr>

How to solve the problem?

Raphael10
  • 2,508
  • 7
  • 22
  • 50
  • Is redis service up and running inside the container? You can check it with `ps -ef | grep -i redis` command. There also pre-built Redis images which run over Debian Buster, so you do not need to install Redis inside the container. Please check https://hub.docker.com/_/redis – usuario Jul 25 '21 at 11:17
  • @usuario Actually redis service is not running inside the container: root@ubuntuone:~# ps -ef | grep -i redis root 770 757 0 07:24 pts/0 00:00:00 grep --color=auto -i redis – Raphael10 Jul 28 '21 at 07:26

1 Answers1

0

After reading your comment, it seems the Redis service has been only installed not started. You can start it using the redis-server binary. After starting it, you will be able to connect.

Also you do not need to install a redis server inside an Ubuntu container. There are already pre-built images of redis over Debian or other SO. Please check Redis Docker Hub

usuario
  • 2,132
  • 1
  • 10
  • 26
  • Thanks @usuario for helping. I updated my post above: redis-server is installed but its daemonized service has some issue – Raphael10 Jul 28 '21 at 08:51