start redis-server on debian/ubuntu boot - redis

I am trying to create a docker container where redis starts at boot.
there will be other foreground services running on that other container which will connect to the redis db.
for some reason the service does not start when i run the container.
here my simplified Dockerfile
FROM debian
# this solves an issue described here:
# http://askubuntu.com/questions/365911/why-the-services-do-not-start-at-installation
RUN sed -i -e s/101/0/g /usr/sbin/policy-rc.d
# install redis-server
RUN apt-get update && apt-get install -y redis-server
# updates init script (redundant)
RUN update-rc.d redis-server defaults
# ping google to keep the container running in foreground
CMD ["ping", "google.com"]
can anybody explain me why this is not working and how this should be done right?

So a docker container is like a full OS but has some key differences. It's not going to run a full init system. It's designed and intended to run a single process tree. While you can run a supervisor such as runit et al within a container, you are really working against the grain of docker and all the tooling and documentation is going to lead you away from using containers like VMs and toward the harmony of 1 process/service per container.
So redis isn't starting because the ping command is literally the only process running in your container.
there will be other foreground services running on that other container which will connect to the redis db.
Don't do it this way. Really. Everything will be easier when you put 1 process in each container and connect them via network links.

Digging up an old question here, but I landed on it whilst trying to package a really simple Redis job queue into an existing docker image setup. I needed it to start up on image boot so the app could have access to it. Memory and performance are not a concern in this scenario or an external Redis server would absolutely be the right choice.
Here's what I did in my Dockerfile for a simple NodeJs app to make it work without editing any system files post-install:
RUN apt-get update && apt-get -y redis-server
CMD service redis-server start & node dist/src/main
Sort of crude using parallel command processes, but as the accepted answer points out this is not a real operating system so we really only care about Redis being online when the app is.

Related

Redis create-cluster create script increases the cpu usage to 100%

I want to give a try to the create-cluster script given in the redis documentation.
I did as the documentation indicates:
./create-cluster start
./create-cluster create
After the ./create-cluster create command, my computer CPU is going indefinitely to 100% of usage.
./create-cluster stop
When stopping the cluster instances, the CPU usage is back to normal usage.
What is going on? What can I do in the configuration to solve this?
My operating system is a Windows 10 version 21H2.
I installed the WSL Ubuntu 20.04 and run redis on it.
I installed the apt-get redis-server package.
didi#CHOUCHOU:~$ redis-server --version
Redis server v=6.2.6 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=9c9e426e2f96cc51
didi#CHOUCHOU:~$ redis-cli --version
redis-cli 6.2.6
I downloaded from github the create-cluster script.
https://raw.githubusercontent.com/redis/redis/6.2/utils/create-cluster/create-cluster

Redis start server if installed via snap

I am new to redis and I've just installed it using snap craft. All tutorials say that i can start redis server by typing redis-server in terminal. But for me it says that Command 'redis-server' not found. Is the process different if installed from snap?
Start Redis server:
sudo snap start redis
To run redis-cli copy it to /usr/local/bin/:
sudo cp /snap/redis/138/usr/bin/redis-cli
redis-cli

Running redis on MacOS - ping works without redis-server

I have just installed redis on MacOS. I'm following through the standard intro process. It says that in order start the DB I should call
$ redis-server
It also says that in order to confirm the server is running I should do the following:
$ redis-cli ping
PONG
I notice that I can ping the redis-cli as above and still get PONG back, even if I haven't executed redis-server. Does this mean that redis is running even if I don't exec redis-server?
If that is the case, how do I start and stop the local db?
Though you did not say, I guess you installed Redis using homebrew.
You can check what services you have started with homebrew using:
brew services list
Then you can use:
brew services start redis
and:
brew services stop redis

how to ask ambari agent not keep quiet when install packages in ubuntu

I'm installing new service in ambari managed cluster. my connection to hortonwork's repo seems too bad, it took lots of time to install ambari-server and ambari-agent it self (onece i almost thought it was dead).
the problem is that when i'm installing new service (e.g zeppelin, it also requires install other dependencies), the progress bar get stuck at 26% percent. it confused me if the installation get stucked or it's just too slow.
the command
ps -ef|grep apt
shows the the install is still there. only can't track the progress via /var/log/apt/term.log like normal apt-get installation (it shows the download progress).
the command shows the apt-get comes with an "-q" options which prevent me from tracking the log file.
so my question is that is there any place i can change the default behavior?
The -q option is added to "apt-get" command based on log level of ambari-agent. I.e. if log level for ambari-agent is set to DEBUG then apt-get without -q option is executed.
You can edit /etc/ambari-agent/conf/logging.conf, in [logger_root] section comment default line level=WARNING and add level=DEBUG. Then retstart ambari-agent. Now if you install any service them apt-get without -q will be executed.
Note:
If /etc/ambari-agent/conf/logging.conf does not exist then copy it from /etc/ambari-agent/conf/logging.conf.sample
Ambari agent specific changed need to be done on all cluster node

Create Docker image from existing Ubuntu + App

I installed Moodle (eLearning PHP based app, but it could be any app) locally on Ubuntu and would like to package it as Docker image/container. There were whole bunch of installations and configurations done. I'd like to package all that so that I can deploy to some Docker enabled hosting service, such as Digital Ocean or AWS.
How do I create Docker image?
Do I need to handle networking, ports and Apache configuration for production deployment?
There ara a lot of Moodle images in dockerhub. just use one of them
The process to create docker images is well documented on Docker's documentation site. See: Build your own images
The idea is simple: You inherit/extend an existing image and make additions to it. This is done in a provisioning file called Dockerfile
Dockerfile Example:
FROM debian:8.4
MAINTAINER John Doe (j.doe#example.com)
# update aptitude
RUN apt-get clean && apt-get update
# utilities
RUN apt-get -y install vim git php5.6 apache2
In the example above I extend a Debian image, update aptitude and install a series of packages.
A full list of commands available in Dockerfiles is available at https://docs.docker.com/engine/reference/builder/
Once your Dockerfile is ready you can build the image using the following command:
docker build -t debian/enhanced:8.4 /path/to/Dockerfile