Create a custom docker image based on docker image
205
mkdir nginx-image
cd nginx-image
create an HTML file that will be used for displaying our static webpage. To do this, enter the following commands: Run this quick and easy install script provided by Docker:
touch index.html
vim index.html
cat index.html
<!DOCTYPE html>
<html>
<head>
<title> Week16 LUIT Project </title>
</head>
<body>
<body style=text-align:center;background-color:red;font-weight:900;font-size:20px;font-family:Helvetica,Arial,sans-serif>
<h1> nginx webpage hosted in a Docker container for ecs01</h1>
<p> This container was deployed: <div id="date"></div></p>
<script>
var date = new Date();
document.getElementById("date").innerHTML=date.toLocaleString();
</script>
</body>
</html>
touch Dockerfile
vim Dockerfile
cat Dockerfile
FROM nginx
RUN apt-get update && apt-get upgrade -y
COPY index.html /usr/share/nginx/html
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
docker build -t nginx_ecs_prac .
Sending build context to Docker daemon 7.168kB
Step 1/5 : FROM nginx
---> 4bb46517cac3
Step 2/5 : RUN apt-get update && apt-get upgrade -y
---> Using cache
---> 26ee57a37bab
Step 3/5 : COPY index.html /usr/share/nginx/html
---> 4260bce1d125
Step 4/5 : EXPOSE 8080
---> Running in f5ef8af0dcc3
Removing intermediate container f5ef8af0dcc3
---> ebd76206232c
Step 5/5 : CMD ["nginx", "-g", "daemon off;"]
---> Running in a2fb3307348c
Removing intermediate container a2fb3307348c
---> 4a949f8e412c
Successfully built 4a949f8e412c
Successfully tagged nginx_ecs_prac:latest
docker tag nginx_ecs_prac banglamon/nginx_ecs_prac
docker push banglamon/nginx_ecs_prac
Content type
Image
Digest
sha256:92582d802…
Size
96.5 MB
Last updated
over 3 years ago
docker pull banglamon/nginx_ecs_prac