AUGERClement
Hello.
I’m trying to learn Docker to container my basic API.
The steps I did are the following :
- Create the API, test it with a postman etc.
- Mix phx.gen.secret (let’s assume SECRET as a value for after)
- As my API has no assets, I didn’t have to compile them.
- Mix phx.gen.release —docker
- Removed lines from Dockerfile which interact with assets
- Docker build
docker run -e DATABASE_URL="ecto://postgres:postgres@localhost/database_dev"
-e SECRET_KEY_BASE=SECRET -p 4000:4000 imageID
I tried multiples variations with my ip instead of localhost, the HOST argument, —network=host, etc. But the error is still
16:36:50.497 [error] Postgrex.Protocol (#PID<0.1887.0>)
failed to connect: ** (DBConnection.ConnectionError) tcp connect
(my_ip:5432): connection refused - :econnrefused
After looking for a bit, I found out that the problem may come from docker permissions, but I couldn’t find anymore stuff.
I feel like I messed up some really basic step, but I can’t find it alone.
Can someone tell me where I did wrong ?
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Latest Phoenix Threads
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Exadra37
You need to provide us with your Dockerfile(s), and Elixir config files in order for us to be able to understand what is wrong.
smita
Hi,
the problem is
localhostinDATABASE_URL. The URL is resolved inside the docker and there is no postgress.AUGERClement
First, the dockerfile is the following, direcly generated by phoenix. I commented assets related stuff (compile and deploy)
Second, I did try with my ip in DATABASE_URL, but nothing changed.
My end goal would be to use docker compose with my app and postgres as services. But trying to use compose when I can’t make a container run correctly seem a bit out of order.
stefanchrobot
Are you trying to connect from the Docker container to the DB that’s running locally? That won’t work by default, you’ll need to open up some ports (sorry, you’ll need to peek into the Docker docs).
Doing this with Docker Compose might actually be easier as it will set some things up for you. Here’s an example (not tested):
AUGERClement
I’m on another project rn, but many thanks, I’ll try this as soon as possible
trisolaran
You can connect to services running on the host machine from a docker container directly using the special hostname:
host.docker.internalSee: https://docs.docker.com/desktop/windows/networking/#use-cases-and-workarounds
(the link is about Windows, but it also works on Mac)
akashv
For linux you will need to add following line to your service needs to access localhost-
Exadra37
Using the
nobodyuser is not advised from a security perspective, androotshouldn’t really be used at all.And was then updated here:
AUGERClement
I read about this issue. But wouldn’t it become rather complex to set up another user (let’s say phoenix) before dropping your docker + compose ?
Doesn’t it defeat the whole point of the “Deploy everywhere” thing ?
AUGERClement
Ok so after trying your thing and many others similar I found across the week, my compose.yml look like that rn :
Now, it seem I can connect the DB because I have those logs for the db service:
along with those for the phoenix app:
For anyone strumbling upon this subject, what I didn’t get was that the service name “db” should be used instead of the IP in the URL.
I’ll mark your answer as solution.