Docker
1 min readNov 20, 2023
docker → java-app
Hello.java
public class Hello{
public static void main(String[] args) {
System.out.println("Hello,dosto");
}
}Dockerfile
# gatting base image from dockerHub
FROM openjdk:11
# working dir. where all code will be kept
WORKDIR app/
# copy system (Hello.java) --> docker container app/ (corrent working dir.)
COPY Hello.java .
# code compile
RUN javac Hello.java # run code line by line and it run only inside the container
# run jaca compile code
CMD ["java","Hello"] # for externally run the code after making container
run flask app-> a micro frame work to run application. in python we use flask and jango , in other language like java we use spring Boot
Get hemant jangir’s stories in your inbox
Join Medium for free to get updates from this writer.
app.py file
from flask import Flask
# Create a Flask application
app = Flask(__name__)
# Define a route for the root URL '/'
@app.route('/')
def hello_world():
return 'Hello, World!'
# Run the app if this file is executed
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)Dockerfile
FROM python:3.9
WORKDIR app/
COPY app.py .
# run like a intermediate layer
RUN pip install Flask # install flask app
CMD [ "python", "app.py" ] #give space inside bracket 





