fly49
Hi, I am trying to get Phoenix app work using containers and elixir releases.
I succeeded to run my app in a single container and connect it to local postgres using dockerfile and command below:
Dockerfile:
FROM elixir:1.9.0-alpine AS build
# install build dependencies
RUN apk add --no-cache build-base npm git python
# prepare build dir
WORKDIR /app
# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
# set build ENV
ENV MIX_ENV=prod
# install mix dependencies
COPY mix.exs mix.lock ./
COPY config config
RUN mix do deps.get, deps.compile
# build assets
COPY assets/package.json assets/package-lock.json ./assets/
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
COPY priv priv
COPY assets assets
RUN npm run --prefix ./assets deploy
RUN mix phx.digest
# compile and build release
COPY lib lib
# uncomment COPY if rel/ exists
# COPY rel rel
RUN mix do compile, release
# prepare release image
FROM alpine:3.9 AS app
RUN apk add --no-cache openssl ncurses-libs
EXPOSE 4000
ENV PORT=4000 \
MIX_ENV=prod \
SHELL=/bin/bash
WORKDIR /app
RUN chown nobody:nobody /app
USER nobody:nobody
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/myapp ./
ENV HOME=/app
CMD ["bin/myapp", "start"]
Commands:
docker build -t test .
docker run \
--network=host \
-e DATABASE_URL=postgresql://postgres:postgres@localhost/myapp_dev \
-e SECRET_KEY_BASE=...some key... \
-e HOST=localhost \
test
But when I am trying to up two containers via docker-compose.yml
version: '3'
services:
PostgreSQL:
image: postgres
container_name: postgres
ports:
- 5433:5432
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_INITDB_ARGS: "--encoding=UTF-8"
hostname: postgres
restart: always
user: root
elixir:
build:
context: .
dockerfile: Dockerfile
env_file:
- .env.list
ports:
- 4040:4000
container_name: elixir
volumes:
- .:/app
depends_on:
- PostgreSQL
.env.list:
DATABASE_URL=postgresql://postgres:postgres@postgres/myapp_prod
SECRET_KEY_BASE=... some key...
HOST=localhost
I am getting an error:
Creating postgres ... done
Creating elixir ... error
ERROR: for elixir Cannot start service elixir: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "bin/myapp": stat bin/myapp: no such file or directory: unknown
ERROR: Encountered errors while bringing up the project.
I suppose that docker-compose should just run elixir container with according dockerfile as just it happens with “docker run …”, but it seems that I get different container which doesn’t have bin/ directory for some reason. Am I missing something?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Marked As Solved- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
pmangalakader
it seems, volume mount for elixir container in the docker-compose overwrites the docker build container files. Try removing the mount and see if that solves the issue.
Also Liked
Exadra37
Never use the root user in any docker image, just like you would not use it in a real server.
The database is open to the internet. You don’t need to expose the ports for the
elixirservice to be able to reach it.This is not necessary, instead just change the name of the docker-compose service from
PostgreSQLtopostgres.If is for running in localhost then you need to do it like
127.0.0.1:4040:4000, otherwise it may be reachable from the internet, unless you have other security measures in place.The use of
4040:4000is equivalent to0.0.0.0:4040:4000, and0.0.0.0means it will be listening in all configured networks on your computer.It’s unsafe to use the
nobodyuser as I report on this issue and now being merged to the official docs.pmangalakader
@fly49 try this, the
chownworked for me:the directory
/home/user, theuserdirectory was owned byrootand hence, the error occurs.fly49
@pmangalakader
Thanks you! It solves the issue!
@Exadra37
Thank you for detailed response, a lot of useful info for me as for docker beginner.
Also I took a look at the PR you mentioned and tried to build a fresh image with new dockerfile, but it has this line:
It seems that “config/runtime.exs” file is not a default thing, at least there is no mentions in docs to create it, and as well I don’t have one.
Last Post!
ambareesha7
Sure I’ll do it, thank you