Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Demonstrating Hello World Python Example for docker init CLI

License

NotificationsYou must be signed in to change notification settings

dockersamples/helloworld-demo-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example used to demonstratedocker init CLI for a simple Hello World Python Program

Run the application

You can simply usepython3 app.py command.

This code defines a handler that responds to GET requests with the specified text and starts an HTTP server listening on port 8080. When you run the script, you can access the server athttp://localhost:8080 and see the same message as the Python program.

Those commands will start a http server listening on port8080and if your requesthttp://localhost:8080 you'll see the following output:

❯ curl http://localhost:8080##         .## ## ##        ==## ## ## ## ##    ===/"""""""""""""""""\___/ ==={                       /  ===-\______ O           __/ \    \         __/  \____\_______/Hello from Docker!

Using Docker init

Run the following command:

 docker init

This utility will walk you through creating the following files with sensible defaults for your project:

  • .dockerignore
  • Dockerfile
  • docker-compose.yaml

Modify the Dockerfile

FROM python:3.8-alpineRUN mkdir /appADD . /appWORKDIR /appCMD ["python3", "app.py"]

Modify the Docker Compose file

 version: '3'services:  app:    build: .    ports:      - "8080:8080"    command: python3 app.py

Running the container service

 docker compose up -d --build

Accessing the Python app

curl localhost:8080         ##         .   ## ## ##        ==## ## ## ## ##    ===/"""""""""""""""""\___/ ==={                       /  ===-\______ O           __/\    \         __/ \____\_______/Hello from Docker!

About

Demonstrating Hello World Python Example for docker init CLI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp