We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Can't even start doing anything.

The moment I enter `docker-compose run web mix do deps.get, compile` I get
** (Mix) Could not find a Mix.Project, please ensure you are running Mix in a directory with a mix.exs file

I did nothing else that follow every instruction. It looked like a good tutorial.

Jaime Iniesta • 8 years ago

Thanks for the guide!

In development, do you use docker-sync so that changes in the code trigger a code reload? I work on OSX but would like to set up the environment with Docker.

David Anguita • 8 years ago

Hola, Jaime!

Well, I've tried tools like docker-sync/docker-dev-osx, but still just using NFS volumes on a docker-machine (VirtualBox) for ease and portability. I see the advantages of using rsync over NFS, but can't tell any noticeable difference in performance between the two at first sight.

Said that, docker-sync seems to be the way to go, I know a bunch of people using it without any issues.

Glad to help, as always :)

Jaime Iniesta • 8 years ago

Gracias David!

It turns out that I didn't need to use docker-sync or NFS - livereload works right out of the box!

I only added `RUN apt-get install -y inotify-tools` to the Dockerfile.

David Anguita • 8 years ago

Good to know! Yep, that should be just enough as filesystem events are propagated instantly. Anyway, I'd give NFS/docker-sync a try. I've noticed a *huge* difference between NFS and osxfs regarding filesystem performance in development.

Thanks for sharing, let's see how it goes!

johndavedecano • 8 years ago

Hello i am having this error please help

```
20:55:20.910 [error] Postgrex.Protocol (#PID<0.312.0>) failed to connect: ** (Postgrex.Error) FATAL (invalid_catalog_name): database "shopit_dev" does not exist
```

jonnyonion • 9 years ago

Hmm, I get an DB connection error on the mix ecto.create step:

(DBConnection.ConnectionError) tcp connect: connection refused - :econnrefused

David Anguita • 9 years ago

It seems the database instance is not reachable. Have you updated your `config/dev.exs` with the proper hostname value?

jonnyonion • 9 years ago

Thx, I was playing with production deployment, but in the meanwhile I've done it with flynn.

Matt • 9 years ago

Just wondering how the phoenix files get generated with out running mix phoenix.new

David Anguita • 9 years ago

Yeah, you are right, it is assumed that a Phoenix app is already initialized. Anyway, it is quite easy to do a fresh install through the Docker container. Let me share the process with you:

1. Create an empty directory for the brand new project and get into it: `$ mkdir <app_name> && cd <app_name>`.
2. Create the `Dockerfile`, `docker-compose.yml` and `.env` files (this one can be just empty) right from the post.
3. Run this command to generate the framework skeleton: `$ docker-compose run web mix phoenix.new . --app <app_name>`. Note that current directory is specified as the project's path.
4. Change the `test` container image from `phoenixbootstrap_web` to `<app_name>_web` in your `docker-compose.yml` file.
5. You should be ready to follow the next steps in the post.

Hope it helps!

Carl Youngblood • 9 years ago

Never mind. Looks like my problem was the lack of an environment variable for MIX_ENV in the Dockerfile. Once I added


ENV MIX_ENV=prod

to the Dockerfile, it worked. That would probably necessitate separate dockerfiles for dev/prod, at least until convox adds support for build variables.

David Anguita • 9 years ago

Hey, I was about to say the same thing ;)

Yes, I'd definitely add an exclusive Dockerfile for this service to not deal with the default MIX_ENV in the containers. Thanks for sharing.

Carl Youngblood • 9 years ago

Thanks for sharing this. This worked for me locally, but now I'm having trouble deploying this to a docker-based service called convox. It halts the web process because the dependencies haven't been installed yet. When I attempt to add the dependency-building steps to the Dockerfile, I get a weird error:

** (Mix) Cannot execute task because the project was not yet compiled. When build_embedded is set to true, "MIX_ENV=prod mix compile" must be explicitly executed

This happens even though I'm explicitly calling mix compile. Any suggestions?

Jonathan Soifer • 9 years ago

It seems to me these steps are related to using Docker as your development and test environment, not to deploy to production.

I'm somewhat used to developing with Docker but never really deployed it to production (Heroku does that automagically, for example).

Jim Cummins • 8 years ago

I fixed this by placing a docker RUN command after adding my app directory. The order is important here because if you do it before, then the app directory won't be found. Here are the last four lines of my Dockerfile:

WORKDIR /app
ADD . /app
RUN mix compile
CMD ["mix", "phoenix.server"]