You are on page 1of 4

DEPARTMENT OF INFORMATION TECHNOLOGY

Semester T.E. Semester V – Information Technology Engineering


Subject DevOps Lab
Subject Professor Prof. Rohit Barve
In-charge
Assisting Teachers -
Laboratory M411A

Student Name Soham Anant Sawant


Roll Number 21101B2002
Grade and
Subject Teacher’s
Signature

Experiment 4 – Docker container port forwarding and file pushing into Docker Hub
Number (Docker - II)
Resources / Hardware: Software:
Apparatus Basic Desktop with Windows or Linux. Git
Required
Theory and 1) Commands how to create container, login and logout
Output • Go to root user:
sudo su

• Create a container:
docker run -it -d --name <name> ubuntu

• Get the id of container using ps:


sudo docker ps

• Open the container in bash:


sudo docker exec -it <container-id> bash

• To logout from the container type exit:


exit
 To stop container and see the status
o Copy the container ID:
docker ps

o To stop container:
docker stop <container-id>

o To see all container status:


docker ps -a

 To remove container:
docker rm <container-id>

2) How to add file in container and push it into hub.docker.com


• First create a container:
docker run -it -d --name <name> ubuntu

• Check it using ps command


docker ps
• Docker images will show all top-level images, their repository and tags,
and their size:
sudo docker images

• Download any image from internet in your current directory (Desktop).


File name is index.jpg

• To push image file in container, copy the container id:


sudo docker commit <container-id> index.jpg

• After that again check all the repository using:


sudo docker images

• Port forwarding is required for hosting the file in the network by


assigning IP to the port:
sudo docker run -it -d -p 85:80 index.jpg

• Create an account at https://hub.docker.com/

• After creating account first login:


sudo docker login
• After that, commit the repository with your docker username:
sudo docker commit <container-id> username/filename

• After committing, push the repository in website with your docker


username:
sudo docker push <committed-repo>

• Log in to your https://hub.docker.com/ account and go to repository


you pushed:

You might also like