1

I have set up a simple nameko server inside of Docker, but when I am trying to curl from the host (Mac) I get an empty reply. I have looked at other similar questions, but it does not work for me, I get:

$ curl http://$(echo docker-machine ip default):8080
curl: (6) Couldn't resolve host 'docker-machine'
curl: (6) Couldn't resolve host 'ip'
curl: (6) Couldn't resolve host 'default'

The OP in that question references some user who explained to them why they are getting the above, but I cannot find that user's comments anymore.

In my case, it appears that it connects, but for some reason the reply is empty:

$curl -i localhost:8080/get/42
curl: (52) Empty reply from server

Here is the file setup:

#install_anaconda.sh
#!/bin/bash
set -e
curl -O https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh
bash Anaconda3-2019.03-Linux-x86_64.sh -b
source ~/.bashrc
export PATH=~/anaconda3/bin:$PATH
conda create --name nameko --yes python=3.6 anaconda
conda update -n base -c defaults conda
source activate nameko
#Dockerfile
FROM ubuntu:latest

WORKDIR /usr/src/app

RUN apt-get update -y && apt-get install curl -y
RUN apt-get install -y python-pip python-dev build-essential 

# to install anaconda
COPY install_anaconda.sh ./
RUN ./install_anaconda.sh

COPY requirements.txt ./
RUN pip install -r requirements.txt

COPY . .

EXPOSE 8080

CMD ["nameko", "run", "email_collector"]
#email_collector.py
#!/usr/bin/env python3
import json
from nameko.web.handlers import http

class HttpService:
    name = "http_service"

    @http('GET', '/get/<int:value>')
    def get_method(self, request, value):
        return json.dumps({'value': value})

    @http('POST', '/post')
    def do_post(self, request):
        return u"received: {}".format(request.get_data(as_text=True))

    @http('GET,PUT,POST,DELETE', '/multi')
    def do_multi(self, request):
        return request.method
#requirements.txt
nameko==2.12.0
Naz
  • 2,012
  • 1
  • 21
  • 45
  • 1
    In the linked answer it's `$(docker ...)` not `$(echo docker...)` ; your command is expanded to `curl http://docker docker-machine default:8080` at which point curl complains that it can't resolve any of these three hosts. – Aaron Apr 25 '19 at 15:05
  • I've tried `$(docker ...)` too. need to execute it again to show what happens – Naz Apr 25 '19 at 17:33
  • `~/git/nameko-docker  curl -i http://$(docker-machine ip default):8080/get/42` `Error getting IP address: Host is not running` `curl: (52) Empty reply from server` prior to this I ran: `docker run -p 8080:8080 nameko_server:latest` – Naz Apr 25 '19 at 18:27

0 Answers0