Deploying microservices in a Docker container


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=“” ENV HTTPS_PROXY=“” ENV http_proxy=“” ENV https_proxy=“” ENV PIP_OPTIONS="–proxy $HTTP_PROXY"

COPY requirements.txt /usr/src/app/ COPY /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 ["./"]

Put the additional python packages you need in a file requirements.txt Flask python-nmap dnspython3 And create your application in the file 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