2. WHAT IS DOCKER?
Docker is a set of platform as a service products that uses OS-level
virtualization to deliver software in packages called containers.
Precisely, it is open platform for developing, shipping, and running
applications.
Assembling above definitions, Docker is an operating system container
management tool that allows you to easily manage and deploy
applications by making it easy to package them within operating system
containers.
3. TO UNDERSTAND DOCKER, THUS WE
MUST FIRST UNDERSTAND CONTAINER
Containerization is the process of packaging an application along with
its required libraries, frameworks, and configuration files together so
that it can be run in various computing environments efficiently.
In simpler terms, containerization is the encapsulation of an
application and its required environment.
4. As containers and virtual machines are many a times used
interchangeably, to know the difference between them becomes
important.
5.
6.
7. WORKING WITH DOCKER
To start with docker, firstly, you need to install docker in your system
through any of the three ways prescribed in the below link.
https://docs.docker.com/engine/install/
8. TO RUN NGINX IN A DOCKER CONTAINER
ON UBUNTU
Nginx is an open source reverse proxy server for HTTP, HTTPS, SMTP,
POP3, and IMAP protocols, as well as a load balancer, HTTP cache,
and a web server (origin server).
So, let’s try to run our first webpage using nginx.
1. To get the nginx image in the system, run the below command.
$sudo docker pull nginx
2. To start this container,
$sudo docker run --name docker-nginx -p 80:80 -d nginx
where –d is used to run the image in background.
Note: As we are working with the ubuntu platform “sudo” must be used before every
command otherwise with Windows or mac no need of using ”sudo”.
9.
10. 3. Paste the IP address of your Ubuntu system into a web browser and
you should see Nginx’s “Welcome to nginx!” page.
11. 4. Thus, to check the status of the container, you can run:
$sudo docker ps
5. Then to stop the running container run:
$sudo docker stop [name-of-the-container-running]
To remove the container :
$sudo docker rm [name-of-the-container-to-be-removed]
12. TO CREATE YOUR OWN WEBPAGE IN
NGINX:
1. Create a new directory within your home directory and hence create
a “index.html” file within it (this is the webpage you want to create).
$mkdir -p ~/docker-nginx/html
$cd ~/docker-nginx/html
$vim index.html
2. Now, to start the container run the below command:
$sudo docker run --name docker-nginx -p 80:80 –d –v ~/docker-
nginx/html:/usr/share/nginx/html nginx
this command tells the system to look for the webpage in the
prescribed location rather than the default one.
13.
14. TO RUN YOUR WEBAPP UPLOADED ON
GITHUB USING DOCKER
Link your docker with the repository on your github through docker hub.
Then login to your docker account by: $sudo docker login
Open and run your repository using : $ sudo docker push USERNAME/appname
Hence, with the ip-address see your webapp running..
15. REFERENCES:
Webapps with docker
https://docker-curriculum.com/#webapps-with-docker
Run nginx in docker
https://vexxhost.com/resources/tutorials/how-to-run-nginx-in-a-docker-
container-on-ubuntu-16-04/
Github and docker
https://github.com/docker/labs/blob/master/beginner/chapters/webapps.md