Skip to content
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

Getting a REDIS_PORT env set to tcp://IP:6379 instead of 6379 #53

Closed
danwdart opened this issue Apr 11, 2016 · 5 comments
Closed

Getting a REDIS_PORT env set to tcp://IP:6379 instead of 6379 #53

danwdart opened this issue Apr 11, 2016 · 5 comments

Comments

@danwdart
Copy link

Hi,

When linking this container with php, I'm getting a REDIS_PORT env being set to tcp://IP:6379 instead of 6379, which just gives me error after error about tcp://172.17.0.7:tcp://172.17.0.7:6379 not existing, which of course it doesn't. Any way we can actually make it a port by default?

At the moment I have to run my containers with -e "REDIS_PORT=6379".

Cheers

@tianon
Copy link
Contributor

tianon commented Apr 18, 2016

This is coming from Docker's linking feature (https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/#environment-variables):

Additionally, Docker creates an environment variable called <alias>_PORT. This variable contains the URL of the source container’s first exposed port. The ‘first’ port is defined as the exposed port with the lowest number. For example, consider the WEBDB_PORT=tcp://172.17.0.82:5432 variable. If that port is used for both tcp and udp, then the tcp one is specified.

The solution I'd probably recommend right now is to use Docker's new networking features (https://docs.docker.com/engine/userguide/networking/dockernetworks/#user-defined-networks) to link containers together, which will allow for transparently supporting Docker Swarm and thus multi-host networking, but will also prevent these extra environment variables from being set.

@5452
Copy link

5452 commented Jun 16, 2017

same issue...

@tianon
Copy link
Contributor

tianon commented Jun 22, 2017

As I noted above, this is a feature of Docker itself (when using --link) which we cannot control or change. If you need REDIS_PORT set to a different value, you'll need to do so explicitly. 👍

@tianon tianon closed this as completed Jun 22, 2017
@digglife
Copy link

digglife commented Aug 4, 2017

This kind of feature should not be enabled by default, I think. It takes me about 1 hour to track down why the hell my container has REDIS_PORT environment variable automatically... Thanks @tianon for explanation.

@maitrungduc1410
Copy link

This took me all day to see why my variable is override when running in Gitlab CICD with Redis as a service, it's linked with my job and cause the problem.

I was having a headache until reading this answer 💯

mtmorgan added a commit to mtmorgan/RedisParam that referenced this issue Jul 26, 2021
…into Jiefei-Wang-change_env

- DO NOT support tcp://... -- this seems to be an artifact of docker,
  rather than a 'feature' redis/docker-library-redis#53
- allow `.error()` and friends to work when `x` is missing
- use NA rather than "" in withr::with_envvar() to unset environment variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants