hi everyone, how can i mix deps.get
when im using docker?
whenever i run docker-compose run web mix phx.new hello
and press yes
, it didnt get past mix deps.get
now if i go to hello
dir and do docker-compose run web mix deps.get
, it says cant find mix project (mix.exs
)
sorry if its a desperate question, im new to docker and I tried numerous sample docker setup via github.
# Dockerfile
version: '3.2'
services:
db:
image: postgres:alpine
web:
build: .
volumes:
- type: bind
source: .
target: /app
ports:
- "4000:4000"
depends_on:
- db
# docker-compose.yml
FROM elixir:alpine
RUN apk add postgresql-client inotify-tools nodejs
RUN mix local.hex --force
RUN mix local.rebar --force
RUN mix archive.install hex phx_new --force
WORKDIR /app
EXPOSE 4000
Hi soyjeansoy!
My first lucky guess is that the container you are running deps.get isn’t configured to sustain the data mix is creating/downloading. If you can put a minimal setup of your codebase/environment anywhere on github, I would be happy to have a look on it for you.
hi @kynoshi thank you for helping me out.
im using this setup. im doing as simple as I can just so I could understand every step.
The docker compose file you uploaded on github is a bit different than the one you put on in this thread. But that’s irrelevant to your issue anyways.
You do not have an elixir issue, rather than a simple folders confusion and/or docker learning opportunity. Setting up the phoenix project using docker-compose run web mix phx.new hello
runs well and uses /app
as your current workfolder.
When you try to update the elixir dependencies using docker-compose run web mix deps.get
you are STILL working inside the /app
folder, but you want to run the command inside /app/hello
where the mix.exs
is located. For a better illustration of what this means, see the screenshot below.
I recommend giving docker-compose run web /bin/sh
a try, to fiddle around a bit inside the container and to get a better mental model of elixir projects inside a docker container.
Have fun! 
2 Likes
oh got it thank you! yea im confused where should i run the commands 
So coincidentally I blogged a couple of days ago about using docker and docker compose with elixir.
The idea was to setup a dev environment with docker as the only dependency needed.
I started with a project folder and all the docker stuff (docker-compose + dockerfile)
Then I did two things to try to make things simpler:
- I created 2 bash scripts
mix
and iex
that wrap docker-compose run app mix/iex
calls
- I created my elixir/phx project directly on the current project directory, e.g:
mix phx.new . --app my_app
The post is in spanish, so i won’t shamelessly plug it here, but I added all the code on this repo (there are numbered branches that show the steps involved)
@emoragaf thank you for helping. You added node in Dockerfile, how can we achieve the same thing with docker-compose.yml?
I guess that you could try to find a base image (or create one and publish it) that already has all the os dependencies that you need. And only define a docker-compose.yml
But in general I would create a Dockerfile for each project