0

I am using the redis docker image. In docker-entrypoint.sh, it has these lines that forces the container to be run as redis user.

# allow the container to be started with `--user`
if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then
    chown -R redis .
    exec su-exec redis "$0" "$@"
fi

The problem is it causes permission problem when I want to create a folder at / to store the socket file.

Opening Unix socket: bind: Permission denied

The only folder that redis has permission to is /data/ which isn't a good place to store socket file and to be accessed by other container. How do I bypass the if block to run redis as root?

(I am aware there is a similar question, but it isn't answered. Also the condition is different. I am using the official docker image so I can't do anything to the Dockerfile.)

netok
  • 181
  • 3
  • 9
  • You’d generally use TCP ports to communicate between containers, not Unix sockets. If you _really_ needed a socket you’d have to bind-mount a host directory that you could set the permissions on. – David Maze Jul 31 '18 at 15:19
  • @DavidMaze How to set permissions in a host directory? The `redis` user isn't a user in the host. – netok Jul 31 '18 at 15:38

0 Answers0