Tools, FAQ, Tutorials:
Build and Run Python Hello Website Image
How to build a Hello Website Docker image using the Python base image? I have the Dockerfile ready.
✍: FYIcenter.com
If you have the Dockerfile ready as shown in the last tutorial,
you continue to build a new Docker image and run it.
1. Build the new image.
fyicenter$ docker image build --tag python-web . Step 1/7 : FROM python ---> a4cc999cf2aa Step 2/7 : WORKDIR /app ---> Running in 936c6b30e70a Step 3/7 : COPY . /app ---> 16af2d71c68d Step 4/7 : RUN pip install --trusted-host pypi.python.org -r package.lst ---> Running in 48985b3ba2d4 ... Installing collected packages: itsdangerous, Werkzeug, MarkupSafe, Jinja2, click, Flask, Redis Removing intermediate container 48985b3ba2d4 ---> 8eece4e03295 Step 5/7 : EXPOSE 80 ---> Running in 3521d3feecb0 Removing intermediate container 3521d3feecb0 ---> e26936f6f2cf Step 6/7 : ENV NAME World ---> Running in 6be383b38da2 Removing intermediate container 6be383b38da2 ---> d29cd293763f Step 7/7 : CMD ["python", "hello-web.py"] ---> Running in 77146103f076 Removing intermediate container 77146103f076 ---> ec5de1c15fa6 Successfully built ec5de1c15fa6 Successfully tagged python-web:latest
2. Create a container and run it.
fyicenter$ docker container run --publish 8080:80 python-web * Serving Flask app "hello-web" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on http://0.0.0.0:80/ (Press CTRL+C to quit) 10.0.2.4 - - "GET / HTTP/1.1" 200 - ... ^C
3. Stop the container with CTRL+C and run it again in background.
fyicenter$ docker container run --publish 8080:80 --detach python-web fyicenter$ docker container list --latest CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS 7da8f1fa7fcc python-web "python hello-web.py" 6 seconds ago Up 3 seconds 0.0.0.0:8080->80/tcp
As you can see, our new Python Hello Website is started now as a Docker container.
⇒ Test Python Hello Website Container
⇐ Requirements to Python Hello Website Image
2020-08-25, ∼1562🔥, 0💬
Popular Posts:
How to use the "return-response" Policy statement to build the response from scratch for an Azure AP...
How To Read a File in Binary Mode in PHP? If you have a file that stores binary data, like an execut...
How to use "link" command tool to link objet files? If you have object files previously compiled by ...
How to use the "@(...)" expression in Azure API Policy? The "@(...)" expression in Azure API Policy ...
How to add request URL Template Parameters to my Azure API operation to make it more user friendly? ...