(mix phx.gen.release --docker) (RuntimeError) couldn't fetch https://hub.docker.com/v2/namespaces/hexpm/repositories/elixir/tags?name=1.15.7-erlang-26.0.2-debian-bullseye-

Help please! I’m running fly launch but getting stuck at the mix phx.gen.release --docker stage. The error code is (RuntimeError) couldn't fetch https://hub.docker.com/v2/namespaces/hexpm/repositories/elixir/tags?name=1.15.7-erlang-26.0.2-debian-bullseye-

I got a feeling it’s my VPN issue since i’m in China. For example I’m unable to run curl -I https://docker.com/ on my vscode cli console. However, I can access docker no problem with my browser.

I have 2 options.
Option 1: Dont use fly launch
I can run the mix phx.gen.release then manually write the docker file. Problem is all the tutorials I see requires me to run fly launch regardless. This means it still gets stuck at the docker stage. Is there another option other than fly launch?

Option 2: Make sure I can call docker.com from my vscode cli
I suspect the call is failing because of my VPN issue. If I can fix this, I can just run the standard fly launch and this would be no problem. Except I’m super confused on how to do this with vscode. What I do know is my VPN listens on a http proxy 59527

It looks like this is missing a version after ..-bullseye-<here> can you check your dockerfile for it

Which phoenix version are you on?

Thank you for helping out @jstiebs !

This link was thrown in the error from running the command mix phx.gen.release --docker.

My project versions:

Erlang/OTP 26
Elixir 1.15.7
{:phoenix, "~> 1.7.2"}

Try updating to latest phoenix 1.7.10 and try again.

Hmmm, so what I did was update phoenix version in my mix.exs file. But I dont think changing the project will affect anything? Correct me if i’m wrong please. I thought that if any fixes was made to the mix phx.gen.release --docker command, it will be through a version bump for elixir, not phoenix.

Regardless, I bumped up the phoenix version to 1.7.10 just to try. Here’s the full error:

❯ mix phx.gen.release --docker
* creating rel/overlays/bin/server
* creating rel/overlays/bin/server.bat
* creating rel/overlays/bin/migrate
* creating rel/overlays/bin/migrate.bat
* creating lib/little_music_book/release.ex

23:44:16.999 [debug] Fetching latest image information from https://hub.docker.com/v2/namespaces/hexpm/repositories/elixir/tags?name=1.15.7-erlang-26.0.2-debian-bullseye-
** (RuntimeError) couldn't fetch https://hub.docker.com/v2/namespaces/hexpm/repositories/elixir/tags?name=1.15.7-erlang-26.0.2-debian-bullseye-: {:error, {:failed_connect, [{:to_address, {~c"hub.docker.com", 443}}, {:inet, [:inet], :etimedout}]}}
    (phoenix 1.7.10) lib/mix/tasks/phx.gen.release.ex:276: Mix.Tasks.Phx.Gen.Release.fetch_body!/1
    (phoenix 1.7.10) lib/mix/tasks/phx.gen.release.ex:205: Mix.Tasks.Phx.Gen.Release.gen_docker/1
    (phoenix 1.7.10) lib/mix/tasks/phx.gen.release.ex:76: Mix.Tasks.Phx.Gen.Release.run/1
    (mix 1.15.7) lib/mix/task.ex:455: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.15.7) lib/mix/cli.ex:92: Mix.CLI.run_task/2
    /opt/homebrew/bin/mix:2: (file)

Side note: It seems the phoenix version is dictated by my elixir version. This can be seen from the error: (phoenix 1.7.10) lib/mix/tasks/phx.gen.release.ex:205: Mix.Tasks.Phx.Gen.Release.gen_docker/1. Doesnt matter which version I set for my project

Yea you are correct I was just hoping it was something more haha.

Your situation is definitely unique, I’m not sure how we can get past it being blocked… the dockerfile template is here

you’d have to set the values manually in the template, or here is the Dockerfile from my machine when I run it.

# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian
# instead of Alpine to avoid DNS resolution issues in production.
# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu
# https://hub.docker.com/_/ubuntu?tab=tags
# This file is based on these images:
#   - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
#   - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20230612-slim - for the release image
#   - https://pkgs.org/ - resource for finding needed packages
#   - Ex: hexpm/elixir:1.15.1-erlang-26.0.2-debian-bullseye-20230612-slim
ARG DEBIAN_VERSION=bullseye-20230612-slim


FROM ${BUILDER_IMAGE} as builder

# install build dependencies
RUN apt-get update -y && apt-get install -y build-essential git \
    && apt-get clean && rm -f /var/lib/apt/lists/*_*

# prepare build dir

# 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 ./
RUN mix deps.get --only $MIX_ENV
RUN mkdir config

# copy compile-time config files before we compile dependencies
# to ensure any relevant config change will trigger the dependencies
# to be re-compiled.
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile

COPY priv priv

COPY lib lib

COPY assets assets

# compile assets
RUN mix assets.deploy

# Compile the release
RUN mix compile

# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/

COPY rel rel
RUN mix release

# start a new build stage so that the final image will only contain
# the compiled release and other runtime necessities

RUN apt-get update -y && \
  apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \
  && apt-get clean && rm -f /var/lib/apt/lists/*_*

# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen


WORKDIR "/app"
RUN chown nobody /app

# set runner ENV
ENV MIX_ENV="prod"

# Only copy the final release from the build stage
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/hello_worlc ./

USER nobody

# If using an environment that doesn't automatically reap zombie processes, it is
# advised to add an init process such as tini via `apt-get install`
# above and adding an entrypoint. See https://github.com/krallin/tini for details
# ENTRYPOINT ["/tini", "--"]

CMD ["/app/bin/server"]


Thank you for sharing the dockerfile. I would still face the problem of deploying it to fly.io. That is because I need to run the fly launch command, which will eventually run mix phx.gen.release --docker under the hood. This means it will get stuck and I cannot create my fly app. Do you have any suggestions on this?

Can skip fly launch and do fly apps create and fly deploy once you have the dockerfile/toml/bin/servers.

You can copy those from https://github.com/fly-apps/live_beats which is mostly up to date and correct.

if you are able to follow golang https://github.com/superfly/flyctl/blob/master/scanner/phoenix.go#L119 would be a helpful resource on what fly launch is doing.

I guess we didn’t have “docker hub gets blocked” on the list of possible issues.

Before I saw your reply, I tried running just mix phx.gen.release and I copied your Dockerfile and .dockerignore file. Then I ran flyctl launch --dockerfile ./Dockerfile. It was able to push to fly successfully I think. The app status currently shows “suspended” which I think means it’s pushed successfully but crashed.

Happy to get new errors:

WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:

need to make sure your fly.toml and application are configured to both use the same port.

Thank you very much for the help!!! I’m almost there.

I’m only getting this error now:

(Postgrex.Error) ERROR 42P01 (undefined_table) relation "musics" does not exist

Does this mean my app is connected to my DB?

Locally I know this means I need to do ecto.create then do ecto.migrate. I’m unsure how to do in on fly.io though. Am I somehow suppose to add it into the Dockerfile like this?:

RUN mix do deps.get, deps.compile

You’ll want to add a release_command for running migrations on boot, or fly ssh console in and run them manully.

Fixed it with this command in my fly.toml:

  release_command = "/app/bin/migrate"

Thank you so much for your help @jstiebs ! Appreciate it very much :slight_smile:

1 Like


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.