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, 1138🔥, 0💬
Popular Posts:
How to add request URL Template Parameters to my Azure API operation 2017 version to make it more us...
How To Merge Cells in a Column? If you want to merge multiple cells vertically in a row, you need to...
How To Control Vertical Alignment? By default, text in all table cells are aligned to the top vertic...
How to build a PHP script to dump Azure AD 2.0 Authentication Response? If you are use the Azure-AD-...
How To Copy Array Values to a List of Variables in PHP? If you want copy all values of an array to a...