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