Cant connect to docker container hosted on fly

I am trying to hit the hostname provided by fly on port 3000 but to no avail. Server is not responding with a response. This is my very first docker app deploy.

app = 'flipkart-scraper-api'
primary_region = 'sin'

[build]

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[[vm]]
  memory = '1gb'
  cpu_kind = 'shared'
  cpus = 1

adding the dockerfile below for reference. Not really sure where am I going wrong.

FROM docker.io/rust:1.73-slim-bullseye as builder
WORKDIR /usr/src/flipkart-scraper-api
RUN apt update && apt install -y libssl-dev
ENV DEPLOYMENT_URL http://localhost:3000
ENV OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu
ENV OPENSSL_INCLUDE_DIR=/usr/include
COPY Cargo.toml .
COPY ./src/ ./src
RUN cargo build --release

FROM docker.io/debian:bullseye-slim
RUN apt update && apt install -y ca-certificates
WORKDIR /usr/local/bin/
COPY --from=builder /usr/src/flipkart-scraper-api/target/release/flipkart-scraper-api .

CMD ["flipkart-scraper-api"]
EXPOSE 3000

In my local development enviroment I used to start the app with
docker run -p3000:0000 flipkart-scraper-api.

Here in fly I have set env variable DEPLOYMENT_URL to the hostname provided by fly.

Hi,

I’m not sure exactly what the app is doing but normally what happens is the port number referenced in the fly.toml is the internal one. Node apps often use port 3000. Sometimes you’ll see 8080.

Since it lists an http service, the outside world will access it on port 80 (http) or port 443 (https).

So … you shouldn’t need to use the port. You load e.g https://app-name.fly.dev in your browser, with no port appended.

If you don’t get a response, try flyctl logs to check the app is running.

I get a message on flyctl logs Starting server on port 3000

If you notice, on your Docker command you specify two ports. The same is true with Fly.io.

[http_service] will map your internal port to ports 80 and 443.

If you want port 3000, replace [http_service] with [[services]]. A minimal example:

[[services]]
  internal_port = 3000
  protocol = "tcp"
  [[services.ports]]
    port = 3000

Depending on your need, you may also want a tls handler and a dedicated IPv4 address.

Hi! I am very inexperienced with this. Can you be a little more descriptive please. I dont have a specific port, Whichever works fine. Also made a typo on the local dev docker command, its -p3000:3000 and not -p3000:0000.

@shyanroy31 Hi, of course we don’t know what your app is doing (do you need a http URL etc) however normally you can simply request your app using its URL. That’s provided by Fly. It has your app’s name as its subdomain. So in your case, that would be:

https://flipkart-scraper-api.fly.dev

Is that URL what you are after? You don’t need to append any port to that.

Unless, as @rubys says, you actually do … and don’t in fact want a http URL for the app.

Hey, Thank you for your input. As it turns out now I am getting somewhat of a output.

{
“total_result”: 0,
“query”: “iphone”,
“fetch_from”: “https://www.flipkart.com/search?marketplace=FLIPKART&q=iphone”,
“result”:
}

But in local dev enviroment I was getting data in the result attribute. I might be wrong but I am guessing this is because of the the server not able to make outbound request. However I made a curl req from the console and able to successfully make a outbound req. Not really sure what might be the issue here.

Once thing to add . In my docker file env is set as http://localhost:3000. Since the deployment would be different here, using

fly set DEPLOYMENT_URL= flipkart-scraper-api.fly.dev

Dockerfile:

FROM docker.io/rust:1.73-slim-bullseye as builder
WORKDIR /usr/src/flipkart-scraper-api
RUN apt update && apt install -y libssl-dev
ENV DEPLOYMENT_URL http://localhost:3000
ENV OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu
ENV OPENSSL_INCLUDE_DIR=/usr/include
COPY Cargo.toml .
COPY ./src/ ./src
RUN cargo build --release

FROM docker.io/debian:bullseye-slim
RUN apt update && apt install -y ca-certificates
WORKDIR /usr/local/bin/
COPY --from=builder /usr/src/flipkart-scraper-api/target/release/flipkart-scraper-api .

CMD ["flipkart-scraper-api"]
EXPOSE 3000

`

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