Skip to content

BirolAYDIN/dockerhub_ Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

docker_ Python

Creating images in Docker using Python, Flask Web App, and Pandas

  • You can try with source code

Image creation steps

  • PyCharm ile New Project

  • Choose Flask application, Existing interpreter

drawing

  • CREATE

  • Flask Project Folder

drawing

  • flaskProject/app, create

  • app/app.py, create

#app/app.py

fromflaskimportFlask,render_template
importpandasaspd
importre


# Python codes.......................
#....................................



app=Flask(__name__)

@app.route('/')
defhello_world():
returnrender_template('index.html',data=data)


if__name__=='__main__':
app.run(host='0.0.0.0',port=5000)
  • app/data.json, create

  • app/templates/index.html,create

  • flaskProject/Dockerfile, create

drawing

  • flaskProject/requirements.txt,create

drawing

#requirements.txt

click==7.1.2
Flask==1.1.2
Jinja2==2.11.2
MarkupSafe==1.1.1
pip==20.2.1
Werkzeug==1.0.1
pandas==1.1.0


Project folder

drawing

  • Acknowledging that Docker is preinstalled

  • We create a docker image named dene2

docker build -t dene2:latest.
  • We create a docker image named flask

drawing

docker run -p 5000:5000 dene2

drawing

  • With CMD + LEFT CLICK we can go to the web page

drawing

  • Now we can send our created flask application container to our storage area on the docker hub.

  • We copy a new image with the same image ID using the 'docker image tag dene2 aydbirol164494/dene2' command.

docker image tag dene2 aydbirol164494/dene2
  • Using the ' docker push aydbirol164494/dene2 ' command, we now send this image file we created to our storage area on the docker hub.

drawing

  • With our control, we can see the 'aydbirol164494/dene2' image file on the docker hub at the same time.

  • In order to test whether we can create a container by downloading the new image file from the hub, we first delete the 'aydbirol164494/dene2' image file using the docker image rm -f 447fafafb619 command.

docker image rm -f 447fafafb619

drawing

  • Again, we must run the command 'docker container run --rm --publish 5000: 5000 aydbirol164494/dene2' and download the image file from the docker hub and use this image to raise our container. We can examine this process from the picture below.
docker container run --rm --publish 5000:5000 aydbirol164494/dene2

drawing

drawing

  • We have learned a brief information about how to create an image file, how to configure and run the Dockerfile file, how to set up containers over the image, and how to use the docker hub.

About

Very simply creating a Docker Image

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published