Skip to content

Latest commit

 

History

History

building_own_image_hands_on

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Basics of Dockerfile

Create a Dockerfile

Use Hello World Dockerfile here

Save it to your current directory

Create a small Hello World html file

Use the Hello World html page here

(You can just have one line <h1>Hello World</h1>)

Build a Docker Image using the Dockerfile and html file

docker build -t nginx:with_website_v0 .

List the images

docker images

Our newly created image is present

Create a Docker Hub Account

https://hub.docker.com/

Login to Docker Account Just Created

docker login
Enter your credentials

Tag your image appropriately

docker tag <image_id> <username>/nginx:with_website_v0

Push your image to Your Public Docker Repository

docker push <username>/nginx:with_website_v0

Go to your repository :)

Remove your just created image and Pull it from Docker Hub

docker rmi <username>/nginx:with_website_v0
docker pull <username>/nginx:with_website_v0

If you already have an nginx image in you local, observe the layer optimization which we learnt in previous section

Run a container using created image

docker run -d -p 8091:80 --name my_container <username>/nginx:with_website_v0

Open your browser and check at port 8091

Hello World html is exposed

Try It Out

Similar to the hello_wold_app, there are files for simple_app with all required elements here

Try creating your own image and push to your repo and run a container using it and expose a port 
Check what is shows !!! :)