[PYTHON] Build Flask environment with Dockerfile + docker-compose.yml

As a memorandum when you want to easily build a flask environment.

Execution environment

Directory structure

test/
   |- Dockerfile
   |- docker-compose.yml
   |- app/
      |- app.py

Description of each file

Dockerfile

FROM ubuntu:latest

RUN apt-get update
RUN apt-get install python3 python3-pip -y

RUN pip3 install flask

RUN mkdir /app

docker-compose.yml

Define the following procedure in this file.

version: '3'
services: 
    web:
        build: .
        command: python3 app/app.py
        volumes:
            - ./app:/app
        ports:
            - 5000:5000

app/app.py

Now you are ready.

Build → Container start → Web server start

$ docker-compose up -d
$ docker-compose ps
   Name           Command         State           Ports         
----------------------------------------------------------------
test_web_1   python3 app/app.py   Up      0.0.0.0:5000->5000/tcp

Recommended Posts

Build Flask environment with Dockerfile + docker-compose.yml
Build python3 environment with ubuntu 16.04
Build python environment with direnv
Build python virtual environment with virtualenv
Build Mysql + Python environment with docker
Build PyPy execution environment with Docker
Build IPython Notebook environment with boot2docker
Easily build a development environment with Laragon
Build Jupyter Lab (Python) environment with Docker
Vue.js + Flask environment construction memorandum ~ with Anaconda3 ~
Build a Tensorflow environment with Raspberry Pi [2020]
Build a Fast API environment with docker-compose
Build Python environment with Anaconda on Mac
[Linux] Build a jenkins environment with Docker
Build a python virtual environment with pyenv
Build a modern Python environment with Neovim
Build AI / machine learning environment with Python
Build NGINX + NGINX Unit + MySQL environment with Docker
[Linux] Build a Docker environment with Amazon Linux 2
Build a C language development environment with a container
Build a WardPress environment on AWS with pulumi
Build Django + NGINX + PostgreSQL development environment with Docker
Build the fastest Django development environment with docker-compose
Build python environment with pyenv on EC2 (ubuntu)
Build Python development environment with Visual Studio Code
Go (Echo) Go Modules × Build development environment with Docker
Build a python environment with ansible on centos6
[Python] Build a Django development environment with Docker
Create a python3 build environment with Sublime Text3
[Memo] Build a virtual environment with Pyenv + anaconda
Build a virtual environment with pyenv and venv
Build a Django development environment with Doker Toolbox
Build Python3 + flask environment on GCP Compute Engine
Build a Python environment with OSX El capitan
Send msgpack with ajax to flask (werkzeug) environment
Quickly build a Python Django environment with IntelliJ
Build PyPy and Python execution environment with Docker
Using Flask with Nginx + gunicorn configuration [Local environment]
Build a Python machine learning environment with a container
Build a python execution environment with VS Code
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a python environment for each directory with pyenv-virtualenv
[Linux] WSL2 Build an environment for laravel7 with Ubuntu 20.04
Build a machine learning application development environment with Python
IP restrictions with Flask
Build a python virtual environment with virtualenv and virtualenvwrapper
Python environment with docker-compose
Build python3.x with pyenv
Quickly build Apache + Pipenv + Flask + SQLAlchemy with Sakura VPS
Build a development environment with Poetry Django Docker Pycharm
Hello world with flask
Programming with Python Flask
Virtual environment with Python 3.6
Build a Django environment for Win10 (with virtual space)
Build a numerical calculation environment with pyenv and miniconda3
Build a data analysis environment with Kedro + MLflow + Github Actions
Build a Django development environment with Docker! (Docker-compose / Django / postgreSQL / nginx)
Build Azure Pipelies with Azure DevOps in a Linux self-hosted environment
Build a machine learning scikit-learn environment with VirtualBox and Ubuntu
[Memo] Build a development environment for Django + Nuxt.js with Docker