This blog walks you through the list of Linux commands to install Docker and deploy an HTML site using Docker and Nginx.
Contents
Docker installation commands
$ sudo yum install -y yum-utils
$ sudo yum-config-manager \
— add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
$ sudo yum install docker-ce docker-ce-cli containerd.io
$ sudo systemctl start docker
$ sudo docker run hello-world
Create HTML page
[[email protected] ~]$ vi hello.html
[[email protected] ~]$ cat hello.html
<P> HELLO WORLD </P>
Steps to deploy HTML site:
[[email protected] ~]$ vi Dockerfile
[[email protected] ~]$ cat Dockerfile
FROM nginx:alpine
COPY . /usr/share/nginx/html[[email protected] html]$ sudo usermod -aG docker $USER && newgrp docker[[email protected] html]$ docker build -t html-server-image:hello_v1 .
Sending build context to Docker daemon 3.072kB
Step 1/2 : FROM nginx:alpine
alpine: Pulling from library/nginx
540db60ca938: Pull complete
197dc8475a23: Pull complete
39ea657007e5: Pull complete
37afbf7d4c3d: Pull complete
0c01f42c3df7: Pull complete
d590d87c9181: Pull complete
Digest: sha256:07ab71a2c8e4ecb19a5a5abcfb3a4f175946c001c8af288b1aa766d67b0d05d2
Status: Downloaded newer image for nginx:alpine
---> a64a6e03b055
Step 2/2 : COPY . /usr/share/nginx/html
---> 131fd26c067f
Successfully built 131fd26c067f
Successfully tagged html-server-image:hello_v1[[email protected] html]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
html-server-image hello_v1 131fd26c067f About a minute ago 22.6MB[[email protected] html]$ docker run -d -p 80:80 html-server-image:hello_v1
dd87e0ff6b5c7f36c788a3113aeeaecf8958d066ec7b357491cafbf09284499f[[email protected] html]$ curl localhost:80/hello.html
<P> HELLO WORLD </P>
Blogs By: Haley Teeples
News By: Annie Bishop
Blogs By: Matthew Caspento
Blogs By: Amar Gurung
Blogs By: Pranjal Goswami
Blogs By: Amar Gurung