2

I have an app with the following services:

  • web/ - holds and runs a python 3 flask web server on port 5000. Uses sqlite3.
  • worker/ - has an index.js file which is a worker for a queue. the web server interacts with this queue using a json API over port 9730. The worker uses redis for storage. The worker also stores data locally in the folder worker/images/

Now I'm trying to make all this work using docker and docker-compose. Being a newbie at those, I'm struggling.

web/Dockerfile

FROM python:3.4-slim

RUN apt-get update
RUN apt-get install -y sqlite3 libsqlite3-dev imagemagick

COPY . /web
WORKDIR /web

RUN pip install -r requirements.txt

worker/Dockerfile

FROM dockerfile/nodejs

COPY . /worker
WORKDIR /worker

RUN npm install

docker-compose.yml

redis:
    image: redis:latest
worker:
    build: ./worker
    ports:
        - "9730:9730"
    links:
        - "redis:redis"
    command: npm start
web:
    build: ./web
    ports:
        - "80:5000"
    links:
        - "worker:worker"
    command: python app.py

docker-compose build works and executes everything just fine.

Now this starts the redis server and the flask server but doesn't start the worker (I know this because I console.log in my worker/index.js and docker-compose up command doesn't print that).

So then I run boot2docker ip to get the IP address, and when I visit it, I get a Gateway timeout error but no error on the docker stderr.

I have been trying a bunch of changes to make it work somehow but can't. I really think it would be helpful if someone could explain what's wrong, and how I can make my setup work.

KGo
  • 18,536
  • 11
  • 31
  • 47
  • Did you open your boot2docker VM (VirtualBox) ports, as I described in http://stackoverflow.com/a/29998490/6309? – VonC May 04 '15 at 05:43
  • I'm on Mac and I've never had to do this before for my other containers. – KGo May 04 '15 at 15:09
  • Did your other container involve mapped port that you had to access directly from your Mac host? – VonC May 04 '15 at 15:31
  • Well I just developed pypa/warehouse which comes with a dockerfile and docker-compose.yml. It worked without any mappings. I did look at their files and it didn't really make much difference. – KGo May 04 '15 at 15:34
  • If there is no port mapping, then there is no need to open port on the VM. But when you map port to your Linux host (which is the boot2docker VM), *then* you need to open port on the VM itself to access it from the actual host (your Mac) – VonC May 04 '15 at 16:46
  • @KaranGoel Could you update your post with the output of compose up (if there is any) ? Because nothing seems wrong with your Dockerfiles and docker-compose.yml. – Vincent Demeester May 05 '15 at 06:55
  • Did you figure this out? Going through a similar set up right now, would love to see your dockerfiles and compose files – applewood Sep 07 '15 at 20:47

1 Answers1

-2

Use command -d to run in the background as the worker starts working initially and slee