Skip to content

ameyrupji-k8s/docker-python-helloworld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

◂ Previous

docker-python-helloworld

Taking the simple python hello world script further. This example creates a docker container containing a python hello world script thar prints "Hello World!".

Note: Refer python-helloworld repo.

Prerequisites

  • Python - >=3.5
  • Visual Studio Code
  • Docker

System Configuration at time of test

  • macOS Catalina - Version 10.15.3
  • Python - Version 3.7.6
  • Docker Desktop - Version 2.2.0.4 (43472)

Initial Setup

Creating Python code

Follow the steps outlined in python-helloworld GitHub project to create a the Python script.

Code

Add Dockerfile

FROM python:3.7-alpine
COPY ./src/helloworld.py helloworld.py

ENTRYPOINT ["python", "helloworld.py"]

Build docker image

To build the docker image run the following command on the terminal: docker build -t python-helloworld:v1 .

terminal-docker-build

To list the created docker images run the command on the terminal: docker images

terminal-docker-images

Test

Run the following command to spin up the container server: docker run python-helloworld:v1

terminal-docker-run

To list all the containers running run this command on the terminal: docker ps -a

terminal-docker-ps-run

Cleanup

To delete the container that was created use this command: docker rm {container_id}

To delete the docker image that was created: docker rmi python-helloworld:v1

Useful Links

Next ▸

About

Dockerizing python hello world

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published