0% found this document useful (0 votes)
11 views2 pages

Docker Build Image

The document outlines the steps to create a simple Flask application in Python that returns 'hello world!' when accessed. It includes instructions for creating a Dockerfile to containerize the application, building a Docker image, and running it as a service. Additionally, it mentions how to push the Docker image to Docker Hub for sharing.

Uploaded by

nickvansteen123
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Docker Build Image

The document outlines the steps to create a simple Flask application in Python that returns 'hello world!' when accessed. It includes instructions for creating a Dockerfile to containerize the application, building a Docker image, and running it as a service. Additionally, it mentions how to push the Docker image to Docker Hub for sharing.

Uploaded by

nickvansteen123
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Create a Python app (without using Docker)

echo 'from flask import Flask


app = Flask(__name__)
@[Link]("/")
def hello():
return "hello world!"
if __name__ == "__main__":
[Link](host="[Link]")' > [Link]

Create a file named Dockerfile and add the following content:

FROM python:3.6.1-alpine
RUN pip install flask
CMD ["python","[Link]"]
COPY [Link] /[Link]

docker image build -t python-hello-world .

docker run --detach \


--name python-hello-world \
-p 5001:5000 \
python-hello-world

docker service create \


--name python-hello-world \
--network file-net \
--publish 5001:5000 \
python-hello-world

Navigate to [Link] in a browser to see the results.


docker login
docker tag python-hello-world jkfels/python-hello-world
docker push jkfels/python-hello-world
Check your image on Docker Hub in your browser.

You might also like