1. create a folder in your local computer.
2. create a file named Dockerfile into the folder
3. content of the Dockerfile:
FROM python:3
ADD hello1.py /
EXPOSE 3334
CMD [ "python", "./hello1.py"]
4. create hello1.py in same folder, containing:
print("Hello1")
5. install Docker desktop for Windows10 from https://www.docker.com/products/docker-desktop, it will require WSL for Windows
6. Open terminal
7. to create docker image named hello2, run:
docker build -t hello2 .
8.to run the image:
docker run -p 3334:3334 hello2
9. you should see output as
Hello1
10. to share your Hello2 image with others:
10a. go to hub.docker.com
10b. create a free account with an ID and create a repository (mine is test), The repository name will be required in the step 10g
10c. open the terminal in the folder location you created in step 1
10d. run the command:
docker login --username=yourhubusername
just with your own user name and email that you used for the account. Enter your password when prompted. If everything worked you will get a message similar to:
Login Succeeded
10e. run the command:
docker images
10f. you will see all the images including Hello2
10g. tag your image, run:
docker tag hello2 YOUR-DOCKERHUBID/REPOSITORY-NAME:hello2
10h. push it to dockerhub, run:
docker push
YOUR-DOCKERHUBID/REPOSITORY-NAME
:hello2
Login to hub.docker.com and you should see your image there.
