![docker tcp api docker tcp api](http://srault95.github.io/docker-proxy-api/img/docker-proxy-api.png)
To build the docker image you need to go to our working directory that Dockerfile is placed and run the following.
Docker tcp api how to#
How to build the Image and run the Container Lastly, we have to specify what command to run within the container using CMD.
Docker tcp api install#
Then we have to install the libraries so we have to add the pip install command to be run. To make it simpler we will not add any subfolders. Then we need to copy the required files from our host machine and add it to the filesystem of the container. You can explore them all at the docker hub. There are a lot of images that you can use like Linux, Linux with preinstalled Python and libraries or images that are made especially for data science projects. The Dockerfile is made of simple commands that define how to build the image. Then we will add some lines of code inside. We only need to create a new file called Dockerfile. If you open the requirements.txt you should see listed all the required libraries of the project. We are using the pip freeze command after activating the projects environment.
![docker tcp api docker tcp api](https://doc.traefik.io/traefik/assets/img/providers/docker.png)
Return jsonify()Īpp.run(debug=True,host='0.0.0.0', port=9007)Īs we said before we have to create the requirements.txt file. #we are importing our function from the colors.py file Return(output.head(n).to_dict()) The main.py from flask import Flask, jsonify, request Output=Series_Colors.value_counts()/len(Series_Colors) Series_Colors = pd.Series(detected_colors) Img = Image.open(BytesIO(ntent))ĭetected_colors.append(closest_colour(image.getpixel((x,y)))) R_c, g_c, b_c = webcolors.hex_to_rgb(key) The colors.py import PILįor key, name in webcolors.css3_hex_to_ems(): The Flask API that we will dockerize uses two. We highly recommend creating a new python environment using Conda or pip so you can easily create your requirements.txt file that contains all the libraries that you are using in the project. It’s a simple API that given an image URL it returns the dominant colors of the image. We will use this Python Rest API Example. In this tutorial, we will show you how you can dockerize easily a Flask API. Not only it makes it easier to create, deploy and run applications but by using containers you are confident that your application will run on any machine regardless of anything that may differ from yours that you created and tested the code. Docker containers are one of the hottest trends in software development right now.