Pages

Monday, 10 July 2017

Docker Example : Hello world ( Creating, push and pull an image and run as a container)






Building app (Image > Container)
Reference for this example 
1
Create a directory
mkdir hello
2
Create these 3 files
Dockerfile         requirements.txt          app.py
3
Building image(app)
docker build -t friendlyhello .                 
4
Running App(container)
docker run -p 4000:80 friendlyhello  (4000 is the OS port and 80 is the port being used by the python in container)
5
Open webbrowser and type
6
NOTE
192.168.99.100 is the default IP address of docker installed OS
7
View the container created
docker ps




Share your image to Docker public registry


Registry
A registry is a collection of repositories

Repository
A repository is a collection of images




Restart the environment
docker-machine restart default

Refresh environment settings
eval $(docker-machine env default)





docker login

Associating a local image with a repository on a registry
username/repository:tag

Tagging an image
docker tag friendlyhello sadakar/get-started:part1


john is the username , get-started is the repository name and part1 is the tag




Pushing the image
docker push sadakar/get-started:part1


docker push sadakar/get-started:part2




Pull and run the image from the remote repository
docker run -p 5000:80 sadakar/get-started:part2





2 comments: