0

I have been working on a project to dockerize and automate redis deployments when i stumbled upon a very weird issue with my build. This is my current Dockerfile

ARG BUILD_VERSION=5
FROM redis:${BUILD_VERSION}

RUN mkdir /var/log/redis
RUN chown -R redis:redis /data /var/log/redis

EXPOSE 6379

WORKDIR /usr/local/etc/redis
CMD ["/usr/local/bin/redis-server", "/etc/redis.conf"]

This is my compose:

version: '2.2'
services:
  redis:
    image: test:red5
    restart: unless-stopped
    ports:
     - "6379:6379"

    user: $UID:$GID

    volumes:
     - /var/lib/redis/:/var/lib/redis/
     - /var/log/redis/:/var/log/redis/
     - /etc/redis.conf:/etc/redis.conf

to be clear i am mounting the redis dirs and configs as volumes because that is whats on the server.. the UID and GID variable gets called in my .env file.

When i docker exec inside the container and run "/usr/local/bin/redis-server", "/etc/redis.conf" the redis server intializes with no problem. but when i run doocker-compose up i get this exit code.

docker-compose up
Creating network "redis_default" with the default driver
Creating redis_redis_1 ... done
Attaching to redis_redis_1
redis_redis_1 exited with code 0

First question ever on stack overflow :).. Assistance is appreciated

logs(bind address issue was already resolved):

I have no name!@b306768fd72f:/usr/local/src$ tail -f /var/log/redis/redis.log
37:C 19 Jan 2022 18:41:09.928 # Configuration loaded
38:M 19 Jan 2022 18:41:09.931 # Could not create server TCP listening socket *:6379: bind: Address already in use
41:C 19 Jan 2022 18:41:40.389 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
41:C 19 Jan 2022 18:41:40.389 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=41, just started
41:C 19 Jan 2022 18:41:40.389 # Configuration loaded
42:M 19 Jan 2022 18:41:40.393 * Running mode=standalone, port=6379.
42:M 19 Jan 2022 18:41:40.393 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
42:M 19 Jan 2022 18:41:40.393 # Server initialized
42:M 19 Jan 2022 18:41:40.394 * DB loaded from disk: 0.001 seconds
42:M 19 Jan 2022 18:41:40.394 * Ready to accept connections
3
  • Welcome to StackOverflow. Can you see the full exception in your logs? And posted in your question. Commented Jan 19, 2022 at 19:08
  • It doesn't seem like that custom image does much, especially since you mount a volume over the directory you create; do you have the same problem if you use an unmodified image: 'redis:5'? Commented Jan 19, 2022 at 19:32
  • yeah the image isnt doing much those are just extra configurations i added.. the test:redis5 is just a tag but the underlying image is redis:5 Commented Jan 19, 2022 at 19:40

1 Answer 1

2

Found the issue in /etc/redis.conf..

daemonize yes

this was blocking docker from running redis-server properly since it was trying to create a pidfile.. container is now running once you comment out this line.

Sign up to request clarification or add additional context in comments.

5 Comments

Should you not rather put the process in the foreground? Demonizing usually puts the process in the background, and this would cause the container to exit immediately. I was about to comment that this might be your problem, when I saw your answer.
So i commented this out and i commented out the pidfile.. to avoid having redis running.
yes that makes sense. Because like is say it puts the process in the backgroud so for docker, there is no process to hold onto and it thats the end of the lifecylce of the container. Maybe describe this a bit better in your answer.
awesome appreciate the help.. ill try to post better questions.. i honestly didint think it had anything to do with the redis.conf
I mean the q is fine but your answer could include at least that you removed or commeted out that line. To me its not clear if you added or removed this line from looking at the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.