Skip to content

Instantly share code, notes, and snippets.

@DamnWidget
Created July 21, 2016 20:38
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DamnWidget/3e58cec118879ed7baa08dc283e162a0 to your computer and use it in GitHub Desktop.
Save DamnWidget/3e58cec118879ed7baa08dc283e162a0 to your computer and use it in GitHub Desktop.
Anaconda docker composer example

Example of usage of anaconda with docker composer

First let's create a new directory called composertest and cd into it:

$ mkdir composertest
$ cd composertest

Then add all the files contained in this gist and run:

$ docker-compose up

The command above will build the web image, pull redis and start a new container with the recently builded web image with anaconda running on it and serving on port 19360

from flask import Flask
from redis import Redis
app = Flask(__name__)
redis = Redis(host='redis', port=6379)
@app.route('/')
def hello():
redis.incr('hits')
return 'Hello World! I have been seen {} times.'.format(redis.get('hits'))
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)
version: '2'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
depends_on:
- redis
anaconda:
image composertest_web
ports:
- "19360:19360"
volumes:
- /home/damnwidget/development/anaconda/anaconda:/opt/anaconda
depends_on:
- web
entrypoint: /opt/anaconda/anaconda_server/docker/start python 19360 docker /opt/anaconda
redis:
image: redis
FROM python:2.7
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
CMD python app.py
@mbriceno
Copy link

mbriceno commented Oct 5, 2017

what image should I use? because the example in the .yaml does not work when running docker-compose up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment