0% found this document useful (0 votes)
4 views

Deploy+Static+HTML+to+docker+container

The document provides a step-by-step guide on deploying a static HTML application to a Docker container, including creating a Dockerfile, building a Docker image, and running a container with port mapping. It outlines the necessary commands for building images, starting, stopping, and removing containers, as well as the importance of using lowercase for image names. Additionally, it explains the use of the COPY keyword for adding files and the -p tag for port mapping between the host and the container.

Uploaded by

r.narender9904
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Deploy+Static+HTML+to+docker+container

The document provides a step-by-step guide on deploying a static HTML application to a Docker container, including creating a Dockerfile, building a Docker image, and running a container with port mapping. It outlines the necessary commands for building images, starting, stopping, and removing containers, as well as the importance of using lowercase for image names. Additionally, it explains the use of the COPY keyword for adding files and the -p tag for port mapping between the host and the container.

Uploaded by

r.narender9904
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Deploy Static HTML to

Docker container

dotnetmastery.com
DOCKER – file creation
 docker file has no extension
 For creating a docker container we need docker
image
 For importing image we use FROM keyword

dotnetmastery.com
DOCKER – file creation

 After importing the required image we have to


copy all the files that we are going to add to in
docker container.
 We use COPY keyword for this.

dotnetmastery.com
DOCKER – Build a docker
image

 docker build –t {dockerimagename} .

NOTE: docker image name should be in lower case, and the above
command should be ran in the same directory where we have
docker file created

dotnetmastery.com
DOCKER – Build a docker
image

 docker build –t {dockerimagename}:1.0.0 .

NOTE: We can give tag to the docker image by using “:” followed by
tag

dotnetmastery.com
DOCKER – Build a docker
image
 If Build is successful we will have image.
 Check it by docker images

dotnetmastery.com
DOCKER – Building
Container
 Docker run -–name {containername}
 -p tag is used for port mapping
 Followed with repository name that we have.

dotnetmastery.com
DOCKER – Port Mapping

 Docker run –name {containername}


 -p tag is used for port mapping between host
and container.

dotnetmastery.com
Docker - PORT Mapping

http://
170.155.10.33:9000

9000

http://
170.155.10.33

80
http://172.17.0.2:80
.NET App

172.17.0.2
Internal IP
Docker Container

Docker Host

docker run –p 9000:80 sample-web-app:1.0

dotnetmastery.com
Docker - PORT Mapping

http:// http://
http://dotnetmastery.com
170.155.10.33:9000 localhost:9500

9000 9500 7000

80 80 5000
http://172.17.0.2:80
.NET App .NET App .NET App

172.17.0.2 172.17.0.3 172.17.0.4


Internal IP
Docker Container Docker Container Docker Container

Docker Host

docker run –p 9000:80 sample-web-app:1.0

dotnetmastery.com
DOCKER – Container
Commands

 docker start 8820b248da9d


 docker stop 8820b248da9d
 docker restart 8820b248da9d
 docker kill 8820b248da9d
Kill will exit the container with status 137

NOTE: You can use either container id (full/partial till it is unique) or container name

dotnetmastery.com
DOCKER – List all
container’s

 docker ps

NOTE: docker ps command displays only active containers

dotnetmastery.com
DOCKER – Remove a container

 docker rm d8b24f3b6773

 docker rm d8b

 docker rm sample-web-app-containerv2

NOTE: Container cannot be removed if it is running. It must be first stopped

dotnetmastery.com

You might also like