3
votes

I'm trying to use IEx.pry in index action from a controller, but doesn't work, I required IEx previously.

 defmodule Registering.DriverController do
   require IEx
   use Registering.Web, :controller
   ....
 end

 def index(conn, _params) do
   drivers = Repo.all(Driver)
   IEx.pry
   ...
 end

when I run docker-compose run web iex -S mix phx.server and reload index router, the iex console doesn't show the debuggin action.

This is my Dockerfile:

FROM elixir:latest

MAINTAINER Your Name <email>

RUN mix local.hex --force

RUN mix archive.install --force https://github.com/phoenixframework/archives/raw/master/phx_new.ez

RUN mix local.rebar --force

WORKDIR /app

And this is my docker-compose.yml:

web:
  build: .
  ports:
    - "4000:4000"
  command: mix phx.server
  environment:
    - MIX_ENV=dev
    - PORT=4000
  volumes:
    - .:/app
  links:
    - db
db:
  image: postgres
  environment:
    - POSTGRES_USER=postgres
    - POSTGRES_PASSWORD=postgres
    - POSTGRES_HOST=db
1
Can you try running with --interactive :-)MartinElvar

1 Answers

2
votes

use docker exec to attach to bash and run your custom iex session. for example:

docker exec -it NAME bash