TimWolla / docker-adminer

Database management in a single PHP file
https://hub.docker.com/_/adminer/
161 stars 70 forks source link

Allow configuring the DB host via an environment variable #19

Closed meghprkh closed 6 years ago

meghprkh commented 6 years ago

Since the links key is deprecated in docker-compose and not present in docker stack deploy, there is no way to reference my db host container which is not named db. Please allow setting database host via an environment variable

meghprkh commented 6 years ago

Clarification: I know that it can be set in the UI but I want its default value to be set to say portalsdb

TimWolla commented 6 years ago

Makes sense and is easy to change: Done.

It will appear in Docker Hub after this is merged: docker-library/official-images#3878

meghprkh commented 6 years ago

I think a note shall also be added in readme. But thanks a lot for the quick response

TimWolla commented 6 years ago

I think a note shall also be added in readme.

Yes. I did not do that yet, because:

a) I don't want it to be a single sentence, but rather add a bit of explanation for the uses (you said docker stack? I have no experience with that.) b) We possibly should update the --link in the examples, not sure. I am still using --link or a network alias for connecting.

Any suggestions from your side? Note: The README in this repository is outdated and should possibly be removed. The canonical one for Docker Hub lives here: https://github.com/docker-library/docs/blob/master/adminer/content.md

danthareja commented 6 years ago

Hey @TimWolla, I've been using adminer with docker-compose in development, and docker stack in production. This piece of information was very important for me to get my prod stack running, and I'd like to suggest some content that you might put into the README so future devs don't have to hunt this deep to find it.


Usage with external server

You can specify a host with the ADMINER_DEFAULT_SERVER environment variable. This is useful if you are connecting to an external server or a docker service named something other than the default db.

docker run -e ADMINER_DEFAULT_SERVER=dbhost -p 8080:8080 %%IMAGE%%

or, via docker-compose up

# docker-compose.yml
adminer:
  image: %%IMAGE%%
  environment:
    - ADMINER_DEFAULT_SERVER=dbhost
  ports:
    - 8080:8080
TimWolla commented 6 years ago

@danthareja Sounds good, thank you. I removed the docker-compose section and reworded it slightly. Watch docker-library/docs#1212 :+1: