-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Set Redis through environment variables #600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
J0WI
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this with a linked Redis container. Redis does already set a REDIS_PORT env to tcp://[ip]:[port], so NextCloud crashes with a server error.
Please also update the example docker-compose files using Redis to avoid conflicts and code duplication:
|
@J0WI Did you test it with v15.0 / Apache / FPM? I have to test the port settings again, it worked when I tried it a few months ago. Do we need the port setting? The port is a default port (like 3306 for MySQL) and people who need to run their own Redis servers on different ports are probably running a non-standard version anyway. |
I used
Yes, the port should be customizable. |
|
@J0WI I have investigated this, and all Redis 5.0 Docker containers have a hardcoded port set (6379). Adding one variable (REDIS_HOST) is sufficient, there are no official Redis containers that use other ports. Shall I change everything to only that single variable? This is in all flavours of the Redis containers:
I tested this on a non-standard Redis container previously, but I think we should stick to the official one. |
|
@marceljd your recent commits didn't made any changes |
|
@J0WI I do not know why there are Dockerfile changes in here, I think they appeared because of the DCO correction I had to maken (force update). Is there any way to remove them? The rest should be ok: REDIS_HOST only because the port is hard-coded in the official Redis images. I also changed the examples and README files. |
SnowMB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try to rebase your changes onto master, then the version changes in the dockerfiles should go away.
|
Tried a few times to get the DCO error out of the way, but unfortunately the instructions given are not working... |
This is only the case, if the nextcloud and redis container are in the same network. But you can expose port
Use |
|
That did not help, now it is one big mess again... And the DCO error is still there unfortunately. I know that you can expose container ports to whatever port you want, but the default Redis containers do not support that directly. If you just want to start a default Redis container from the official image the way that is described in the examples than you do not have a choice. It runs on 6379 and this image does not support any environment variables out of the box. So that is why I think this is sufficient. MySQL has a documented way of changing the default port though an environment variable, I think that is a different case. For Redis you should use the Bitnami version instead. My solution is the easy way for the official Redis container, it just works. |
Yeah but in most cases you would not expose your redis container on a network outside the host. When you use for example 2 servers (docker hosts) one running redis and the other one running nextcloud, nextcloud would connect to a port on the 2nd host. and there the redis port could be anything because of the required port mapping to the host. It would just look like this: An other example would be someone running redis natively. The fix is fairly easy: Just introduce a 2nd variable called In the config (untested): 'redis' => array(
'host' => getenv('REDIS_HOST'),
'port' => getenv('REDIS_PORT') ? getenv('REDIS_PORT') : 6379
), |
|
We can't use
But changing the name of the variable should work. |
|
Oh missed that. Maybe |
I had this in the original config already (slightly different), but I am still wondering what the use case would be. In my opinion most users will start up 3 containers: SQL, webserver and redis. If you start them together they will connect on standard ports, no further config needed. The example configs and environment variables are not ment for expert users, they will change the config with custom Dockerfiles anyway. And a non-expert will not run a Redis server outside of the cluster. What you certainly do not want is non-expert users exposing host-ports to the outside world running a redis server. You want them to stay within the docker-compose boundaries, and exposing ports 80 and 443 to the outside world is more than enough. So I do not see the point of adding custom ports to this. Running Redis is faster and gets rid of file locks, so I think everyone should run 3 instead of only 2 containers, but adding custom ports will only be more complicated and insecure, especially if you are not an expert. |
|
Completely agree: most users will not ever use this and most users will run their setup on one host and most users may not have enough expertise to fiddle around with the details. (Including myself as I'm missing quite a bit of whats needed for proper server administration) That said, I think in this case adding the possibility to change the redis port is very straight forward on both the documentation and the implementation side so that this feature is completely opt-in. For a normal user nothing changes and he never has to worry about setting this port to any value. |
|
There is a great example at nextcloud/server#13148 (comment) |
I don't know, looks like the issue is a routing problem with CSFR errors. This should be solvable with the sticky settings in Kubernetes, I would not try to solve networking problems in an application. But perhaps I misunderstood the exact problem. Besides: they still use the default port. @J0WI @SnowMB I added the port to the config files and the README, but I did not include them in the examples on purpose because I think these should be as simple as possible. Should I? And I still have trouble with the DCO check. I tried to rebase and signoff, but it still does not work. When it is necessary I think I need to create a new branch and change the files again, or do you have the golden hint? |
|
Use |
|
@J0WI The files are correct now but I cannot get rid of the commits that are in the branch already. I cannot get the signoff to work. I think the only possibility is to remove the entire fork and my local copies and start from scratch. I already lost too much time playing around with Git, is there any way to get this to work without trying for hours? The info on the internet was not really helpfull, tried just about everything except deleting everything and start over again. |
|
@marceljd i manged to clean up most of the mess locally. I can force push it to your branch if you want me to. |
|
@tilosp I would be very happy! Next time I will be very careful not to create this kind of mess again :-) Thank you very much! |
|
@tilosp , is it safe to signoff with these commands now, or do you have to sign because you pushed?
|
|
@marceljd the commit mess is gone but there is still some sign off problem. git clone https://github.com/marceljd/docker.git -b redis-env-vars
git rebase HEAD~8 --signoff
git push --force origin redis-env-vars |
Signed-off-by: marceljd <support@dihosting.ch>
Signed-off-by: marceljd <support@dihosting.ch>
Signed-off-by: marceljd <support@dihosting.ch>
Signed-off-by: marceljd <support@dihosting.ch>
modified: .config/redis.config.php modified: .examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml modified: .examples/docker-compose/insecure/mariadb-cron-redis/fpm/docker-compose.yml modified: .examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml modified: .examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml modified: 13.0/apache/Dockerfile modified: 13.0/apache/config/redis.config.php modified: 13.0/fpm-alpine/Dockerfile modified: 13.0/fpm-alpine/config/redis.config.php modified: 13.0/fpm/Dockerfile modified: 13.0/fpm/config/redis.config.php modified: 14.0/apache/Dockerfile modified: 14.0/apache/config/redis.config.php modified: 14.0/fpm-alpine/Dockerfile modified: 14.0/fpm-alpine/config/redis.config.php modified: 14.0/fpm/Dockerfile modified: 14.0/fpm/config/redis.config.php modified: 15.0/apache/Dockerfile modified: 15.0/apache/config/redis.config.php modified: 15.0/fpm-alpine/Dockerfile modified: 15.0/fpm-alpine/config/redis.config.php modified: 15.0/fpm/Dockerfile modified: 15.0/fpm/config/redis.config.php modified: README.md Signed-off-by: marceljd <support@dihosting.ch>
Signed-off-by: marceljd <support@dihosting.ch>
added REDIS_HOST_PORT Changes to be committed: modified: .config/redis.config.php modified: README.md Signed-off-by: marceljd <support@dihosting.ch>
run update.sh Changes to be committed: modified: 13.0/apache/config/redis.config.php modified: 13.0/fpm-alpine/config/redis.config.php modified: 13.0/fpm/config/redis.config.php modified: 14.0/apache/config/redis.config.php modified: 14.0/fpm-alpine/config/redis.config.php modified: 14.0/fpm/config/redis.config.php modified: 15.0/apache/config/redis.config.php modified: 15.0/fpm-alpine/config/redis.config.php modified: 15.0/fpm/config/redis.config.php Signed-off-by: marceljd <support@dihosting.ch>
.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml
Show resolved
Hide resolved
On branch redis-env-vars Changes to be committed: deleted: ../../apache/app/redis.config.php deleted: redis.config.php deleted: ../../../../with-nginx-proxy/mariadb-cron-redis/apache/app/redis.config.php deleted: ../../../../with-nginx-proxy/mariadb-cron-redis/fpm/app/redis.config.php Signed-off-by: marceljd <support@dihosting.ch>
J0WI
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
SnowMB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
@tilosp could you merge this once RC are removed? |
|
Please keep your fork until this is merged. |
@J0WI added memcache.distributed