How to place html file in docker webserver and push it to Google Container Registry(GCR) in GCP ?

In this article, we will see how to place html file in docker webserver.

And then push it to Google Container Registry(GCR) in GCP.

Lets have a look step by step to understand the scenario.

 

1. Run the webserver in daemon mode in background.

saketalwar2@cloudshell:~/docker1$ docker run -p 8080:80 -d nginx:latest
8e3b6d0e58812152876e7766c877d5498e492af672855fa371966016fa7316f8

 

2. Create a new html file.

 
saketalwar2@cloudshell:~/docker1$ echo "<h2>Welcome to NGE Linux KB Articles</h2>" > ./index.html

 

3. Check out the current docker processes.

saketalwar2@cloudshell:~/docker1$ docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                  NAMES
8e3b6d0e5881   nginx:latest   "/docker-entrypoint.…"   17 minutes ago   Up 17 minutes   0.0.0.0:8080->80/tcp   ecstatic_wu

 

4. Now copy the file to required instance.

saketalwar2@cloudshell:~/docker1$ docker cp ./index.html 8e3b6d0e5881:/usr/share/nginx/html/

 

5. Now we can run and see our new page in place.


 

6. Build new image with latest changes in place.

saketalwar2@cloudshell:~/docker1$ docker commit 8e3b6d0e5881 nge1:newimage1
sha256:07c0be2127a2107d5b8fa19aeb73ce387098f28b09ea9fdb31fe5765533264da

saketalwar2@cloudshell:~/docker1$ docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                  NAMES
8e3b6d0e5881   nginx:latest   "/docker-entrypoint.…"   24 minutes ago   Up 24 minutes   0.0.0.0:8080->80/tcp   ecstatic_wu

saketalwar2@cloudshell:~/docker1$ docker images
REPOSITORY   TAG         IMAGE ID       CREATED          SIZE
nge1         newimage1   07c0be2127a2   25 seconds ago   141MB
nginx        latest      605c77e624dd   12 days ago      141MB

 

7. Lets push the container in GCR.
GCR is Google Container Registry storage provided by google.

saketalwar2@cloudshell:~/docker1$ docker tag nge:nginx1 us.gcr.io/nge:nginx1

saketalwar2@cloudshell:~/docker1$ docker push us.gcr.io/nge
Using default tag: latest
The push refers to repository [us.gcr.io/nge]
tag does not exist: us.gcr.io/nge:latest

saketalwar2@cloudshell:~/docker1$ docker push us.gcr.io/nge:nginx1
The push refers to repository [us.gcr.io/nge]
a382c5245d56: Retrying in 17 seconds
d874fd2bc83b: Retrying in 19 seconds
32ce5f6a5106: Retrying in 19 seconds
f1db227348d0: Retrying in 18 seconds
b8d6e692a25e: Retrying in 18 seconds
e379e8aedd4d: Waiting
2edcec3590a4: Waiting
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments