Deploying microservices in a Docker container

2015-12-11

I already spoke about docker containers (moving datacenters apps from virtual machines to containers) This is a quick tutorial (my github sample code) about a new way of deploying (micro) services and applications, ie using Docker containers: a sample python webservice and an simple web (html + angularJS code) page Creating docker containers means defining a file Dockerfile like``` FROM python:3.5 #FROM python:3-onbuild

ENV DEBIAN_FRONTEND noninteractive

ENV HTTP_PROXY=“http://myproxy.redaelli.org:80” ENV HTTPS_PROXY=“http://myproxy.redaelli.org:80” ENV http_proxy=“http://myproxy.redaelli.org:80” ENV https_proxy=“http://myproxy.redaelli.org:80” ENV PIP_OPTIONS="–proxy $HTTP_PROXY"

COPY requirements.txt /usr/src/app/ COPY app.py /usr/src/app/

WORKDIR /usr/src/app RUN apt-get update && apt-get install -y nmap RUN pip install –proxy $HTTP_PROXY –no-cache-dir -r requirements.txt

VOLUME ["/usr/src/app"] EXPOSE 5000

ENTRYPOINT [“python”] CMD ["./app.py"]

Put the additional python packages you need in a file requirements.txt Flask python-nmap dnspython3 And create your application in the file app.py In this way we are going to create a docker container with python3 and some additional python packages with the command docker build -t python-infra-ws . Finally we'll start the container with the command docker run -d -t –name python-infra-ws -p 5000:5000 python-infra-ws Some other useful commands are: docker stop python-infra-ws docker start python-infra-ws docker ps python-infra-ws docker rm python-infra-ws docker rmi python-infra-ws


Enter your instance's address


More posts like this