Hi guys,
I will try to show you here how u can learn to build a image using docker and run that image later as a container.
I will build a image to run a webserver with static content in it and for this I will use nginx image which is available in docker hub .
Hoping that you have already installed docker package in your machine.
Below are the steps to build a simple docker image:
1. Create a Docker file and add below contents
"From nginx" indicates that docker should use nginx image. If nginx image is available in local repository then it will use that else it will download from docker hub
"COPY index.html /usr/share/nginx/html" says that copy the index.html which is available in current directory to directory /usr/share/nginx/html
2. Create index.html which is required as per above steps in same directory
3. Build the image
mynginx is the image name given and v1 is the tag for that image
Please note that at the end of command there is a dot '.' which indicates that docker should pick files from current directory
4. List the images
Once the image build is successful verify that image is listed
5. Create a container
We will now create a container with image which we have just built
5. Verify if container created
We will verify if myweb container is created successfully
6. Access the webserver
I will try to show you here how u can learn to build a image using docker and run that image later as a container.
I will build a image to run a webserver with static content in it and for this I will use nginx image which is available in docker hub .
Hoping that you have already installed docker package in your machine.
Below are the steps to build a simple docker image:
1. Create a Docker file and add below contents
"From nginx" indicates that docker should use nginx image. If nginx image is available in local repository then it will use that else it will download from docker hub
"COPY index.html /usr/share/nginx/html" says that copy the index.html which is available in current directory to directory /usr/share/nginx/html
2. Create index.html which is required as per above steps in same directory
3. Build the image
mynginx is the image name given and v1 is the tag for that image
Please note that at the end of command there is a dot '.' which indicates that docker should pick files from current directory
4. List the images
Once the image build is successful verify that image is listed
5. Create a container
We will now create a container with image which we have just built
5. Verify if container created
We will verify if myweb container is created successfully
6. Access the webserver
Comments
Post a Comment