Pushing a docker image to docker hub
First you need to have an account in docker hub.
Create an account in docker hub.
https://hub.docker.com/
Create an instance in aws console (refer how to create an instance)
Login to gitbash(refer how to login to an instance in ssh client)
Install docker in an instance
Check the service is running or not.
Switch to root user----------------->sudo su
To install docker------------------->yum install docker
To start the service--------------->systemctl start docker
To check whether the service is running or not ---------------->ps-ef | grep -i docker
Now start the service
Now the server is running or not
Now install nodejs application inside the docker and push the image to docker hub.
First make a directory name as docker
Inside the directory install nodejs application
You can get nodejs from https://github.com/luksa/kubernetes-in-action/tree/master/chapter02/kubia
From that you can pull the image to your local.
Now get nodejs file.
Go to the link click on dockerfile,click on raw copy the url.
Click on raw you will get a page there copy the url
Go to the git bash and enter the command
#wget https://raw.githubusercontent.com/luksa/kubernetes-in-action/master/chapter02/kubia/Dockerfile
Now click on app.js file copy the file and install in git bash
Make sure that you should have the both files in your docker folder
Now build the image
#docker build -t nodejs.
Now check whether image is build are not
Use the command ;docker images
Now run the container---------------->docker run -d -p<ports><imagename>
docker run -d -p 8080:8080 nodejs
Now check whether container running or not:-------------------------->docker ps
Now check in the browser by giving Ip addresss
ipaddress:<hostport>
Its working..
Now push this image to docker hub.
Login to the docker hub account
Create a repository
Tag this image and push to docker hub.
Click on create repository
Copy the right side command and paste in any wordpad
We will use those while tagging the images and pushing the image to docker hub.
Now give name to repository
Eg:nodejs
And Click on create
You will get the page like this
And copy the right side command .We will use this to push the image to docker hub.
Now go to gitbash login to the docker hub----------------->#docker login
Enter your docker id and password
Now tag the image
#docker tag <image><dockerid>/repository name:latest
docker tag nodejs<username>/nodjs-web:1
Now push the image to the docker hub
docker push<username>/nodjs-web:1
Now go the docker hub whether the image is pushed or not
Execrise: 1)Build images of httpd,flask app,nodejs app and push them in docker hub
2) Take an redhat ami install docker and build an images and try push the images to docker hub.
Comments
Post a Comment