Dockerize a Flask Project

$ sudo apt-get install
$ docker version
Version: 1.12.6
API version: 1.24
Go version: go1.7.4
Git commit: 78d1802
Built: Tue Mar 14 09:47:15 2017
OS/Arch: linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sudo usermod -aG docker $USER
$ python 
* Running on (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 135-043-124
# Usage: ADD [source directory or URL] [destination directory]
ADD /my_app_folder /my_app_folder
# Usage 1: CMD application "argument", "argument", ..
CMD "echo" "Hello docker!"
# Usage: ENTRYPOINT application "argument", "argument", ..
# Remember: arguments are optional. They can be provided by CMD
# or during the creation of a container.

# Usage example with CMD:
# Arguments set with CMD can be overridden during *run*
CMD "Hello docker!"
# Usage: ENV key value
# Usage: EXPOSE [port]
# Usage: FROM [image name]
FROM ubuntu
# Usage: MAINTAINER [name]
MAINTAINER authors_name
# Usage: RUN [command]
RUN aptitude install -y riak
# Usage: USER [UID]
USER 751
# Usage: VOLUME ["/dir_1", "/dir_2" ..]
VOLUME ["/my_files"]
# Usage: WORKDIR /path

Let’s make our Dockerfile!

FROM ubuntu:latest
MAINTAINER Angello Maggio ""
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
ADD . /flask-app
WORKDIR /flask-app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD [""]
docker build -t my-flask-image:latest .
my-flask-image latest 65024886bcee About a minute ago 430 MB
ubuntu latest d355ed3537e9 2 weeks ago 119.2 MB
$ docker run -d -p 5000:5000 my-flask-image




Python Coder — DevOps Padawan — Total Nerd

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Setup SSH using Tailscale or ngrok

Quarkus Deployment with Openshift and AWS

Security Integration into DevOps with AWS — Why and How

Introducing dx-punch

Why you should use docker from day 1?

Docker Introduction

How to Efficiently Work with Pandas and S3

Visualizing real-time traffic patterns using HERE traffic api

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Angello Maggio

Angello Maggio

Python Coder — DevOps Padawan — Total Nerd

More from Medium

GraphQL with Python — Part-2

How to run a Python Program within an AWS EC2 Instance

Build a CI pipeline with GitHub Actions for Python Project

Creating a login API with Flask