Coder Social home page Coder Social logo

Comments (8)

hiett avatar hiett commented on June 27, 2024 1

(for reference, docker ps -a should show all containers, including stopped ones.)

from serverless-redis-http.

hiett avatar hiett commented on June 27, 2024 1

There is a docker compose example in the readme that will work out-of-the-box on any operating system: https://github.com/hiett/serverless-redis-http?tab=readme-ov-file#via-docker-compose

This is the recommended way to run, and a lot easier (because you can stop and start redis & srh at the same time!)

Closing this issue because it's general docker issues rather than anything specific with SRH

from serverless-redis-http.

hiett avatar hiett commented on June 27, 2024

You shouldn't need a tokens.json file -- the env command will work just fine.
The problem is actually networking. When you put localhost (or 127.0.0.1, same thing), it is looking inside the docker container. It isn't the same localhost as your parent machine.

Not to worry though -- there is an easy fix for this. Assuming you are using Windows or Mac, you can use host.docker.internal as the IP:

sudo docker run \
    -it -d -p 8080:80 --name srh \
    -e SRH_MODE=env \
    -e SRH_TOKEN=your_token_here \
    -e SRH_CONNECTION_STRING="redis://host.docker.internal:6379" \
    hiett/serverless-redis-http:latest

This will automatically resolve to your parent system's private IP, and should do the trick!

from serverless-redis-http.

dBianchii avatar dBianchii commented on June 27, 2024

So fast to answer. Thanks a lot. I am actually on Linux Ubuntu.

When I try to run this command, or the command listed in the readme, I get this:

sudo docker run \                                                                                                                         10:39:14 
    -it -d -p 8080:80 --name srh \
    -e SRH_MODE=env \
    -e SRH_TOKEN=your_token_here \
    -e SRH_CONNECTION_STRING="redis://host.docker.internal:6379" \
    hiett/serverless-redis-http:latest
docker: Error response from daemon: Conflict. The container name "/srh" is already in use by container "6b44fb4700db981572d6995e2ec3253427667e3961542af66af27f9dbf8b89a1". You have to remove (or rename) that container to be able to reuse that name.

However, sudo docker ps is empty. There aren't any running containers

from serverless-redis-http.

hiett avatar hiett commented on June 27, 2024

This is because the the container is likely stopped in the background, but not removed. you can run docker rm srh, that should do the trick.

Linux is a bit different -- you might have issues with host.docker.internal. That is a feature of Docker Desktop specifically, not built into the normal Docker engine.

You can use the static IP 172.17.0.1. This should work on linux and will be bound to the parent machine's IP

from serverless-redis-http.

dBianchii avatar dBianchii commented on June 27, 2024

Thanks so much @hiett. I didn't know about docker ps -a command. I managed to remove the container, and then I ran this command:

sudo docker run \
    -it -d -p 8080:80 --name srh \
    -e SRH_MODE=env \
    -e SRH_TOKEN=your_token_here \
    -e SRH_CONNECTION_STRING="redis://172.17.0.1:6379" \
    hiett/serverless-redis-http:latest

I managed to connect to the SRH server from my Next.JS local instance, but still it cannot connect to the redis server running on the parent machine.
Guess i'll do more digging around to understand how to make the container talk to the parent machine. If you have any other suggestions I could try let me know.

Maybe after I manage to do it, we can have a tutorial settings on README for linux? Just a suggestion

from serverless-redis-http.

dBianchii avatar dBianchii commented on June 27, 2024

Maybe would it work if I ran redis inside the container? So that the connection wouldn't need to leave it...

from serverless-redis-http.

dBianchii avatar dBianchii commented on June 27, 2024

Hey, thanks so much! Much better to use docker-compose. Definitely need to use and feel more confident with docker.

Thanks for creating this repo!

from serverless-redis-http.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.