{"id":6338,"date":"2021-06-19T20:37:17","date_gmt":"2021-06-19T15:07:17","guid":{"rendered":"https:\/\/blog.pheonixsolutions.com\/?p=6338"},"modified":"2021-06-19T21:33:20","modified_gmt":"2021-06-19T16:03:20","slug":"deploy-a-sample-app-with-docker-over-ssl","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/","title":{"rendered":"Deploy a sample app with Docker over SSL"},"content":{"rendered":"\n<p>1)To achieve the above, first we need to install docker. Please follow the below link to install docker.<br>https:\/\/docs.docker.com\/engine\/install\/ubuntu\/#install-using-the-repository<\/p>\n\n\n\n<p>2) Create a sample application. Create a directory called &#8220;helloapp&#8221;. Create file index.js.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">mkdir helloapp<br>cd helloapp<br>vi index.js<\/span><br><br>3) Copy and paste the below content.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"has-inline-color has-vivid-cyan-blue-color\">const express = require(&#8220;express&#8221;);<br>const app = express();<br>app.get(&#8220;\/&#8221;, (req, res) =&gt; {<br>res.send(&#8220;Hi Everyone ! Welcome to Pheonix Solutions&#8221;);<br>});<br>app.listen(8080, () =&gt; {<br>console.log(&#8220;Server started on port 8080&#8221;);<br>});<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>4) Create a file with name package.json<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">vi package.json<\/span><br><br>5) Copy and paste the below content.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"has-inline-color has-vivid-cyan-blue-color\">{<br><br>&#8220;dependencies&#8221;: {<br><br>&#8220;express&#8221;: &#8220;*&#8221;<br><br>},<br><br>&#8220;scripts&#8221;: {<br><br>&#8220;start&#8221;: &#8220;node index.js&#8221;<br><br>}<br>}<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>6) Now create a Docker file. Dockerfile contains instructions for building a Node application using the Docker node:alpine image and the contents of your current project directory.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">vi Dockerfile<\/span><br><br>7) Now copy and paste the below content. These instructions build a Node image by copying the project code from the current directory to the container and installing dependencies with npm install. They also take advantage of Docker\u2019s caching and image layering by separating the copy of package.json and package-lock.json, containing the project\u2019s listed dependencies, from the copy of the rest of the application code.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"has-inline-color has-vivid-cyan-blue-color\">#base image<br>FROM node:alpine<br><br><br>#install dependancies<br>WORKDIR \/usr\/helloapp<br>COPY .\/package.json .\/<br>RUN npm install<br>COPY .\/ .\/<br><br><br>EXPOSE 8080<br>#start-up command<br>CMD [&#8220;npm&#8221;, &#8220;start&#8221;]<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>8) Create a directory in the current project directory for the configuration file<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">mkdir nginx-conf<br>nano nginx-conf\/nginx.conf<\/span><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"has-inline-color has-vivid-cyan-blue-color\">server {<br>listen 80;<br>listen [::]:80;<br><br><br>root \/var\/www\/html;<br>index index.html index.htm index.nginx-debian.html;<br><br><br>server_name dockertestings.pheonixsolutions.com www.dockertestings.pheonixsolutions.com;<br><br><br>location \/ {<br>proxy_pass http:\/\/dockertestings.pheonixsolutions.com:8080;<br>}<br><br><br>location ~ \/.well-known\/acme-challenge {<br>allow all;<br>root \/var\/www\/html;<br>}<br>}<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>9) Next we will create a docker-compose file. The docker-compose.yml file will define our services, including the Node application and web server. It will specify details like named volumes, which will be critical to sharing SSL credentials between containers, as well as network and port information. It will also allow us to specify specific commands to run when our containers are created. This file is the central resource that will define how our services will work together.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">nano docker-compose.yml<\/span><\/p>\n\n\n\n<p>Copy and paste the below content.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"has-inline-color has-vivid-cyan-blue-color\">version: &#8216;3&#8217;<br>services:<br>nodejs:<br>build:<br>context: .<br>dockerfile: Dockerfile<br>image: helloapp<br>container_name: helloapp<\/span><br><span class=\"has-inline-color has-vivid-cyan-blue-color\">ports:<br>&#8211; &#8220;8080:8080&#8221;<br>restart: always<br>networks:<br>&#8211; app-network<br>webserver:<br>image: nginx:mainline-alpine<br>container_name: webserver<br>restart: always<br>ports:<br>&#8211; &#8220;80:80&#8221;<br>volumes:<br>&#8211; web-root:\/var\/www\/html<br>&#8211; .\/nginx-conf:\/etc\/nginx\/conf.d<br>&#8211; certbot-etc:\/etc\/letsencrypt<br>&#8211; certbot-var:\/var\/lib\/letsencrypt<br>depends_on:<br>&#8211; nodejs<br>networks:<br>&#8211; app-network<br>certbot:<br>image: certbot\/certbot<br>container_name: certbot<br>volumes:<br>&#8211; certbot-etc:\/etc\/letsencrypt<br>&#8211; certbot-var:\/var\/lib\/letsencrypt<br>&#8211; web-root:\/var\/www\/html<br>depends_on:<br>&#8211; webserver<br>command: certonly &#8211;webroot &#8211;webroot-path=\/var\/www\/html &#8211;email abc@example.com &#8211;agree-tos &#8211;no-eff-email &#8211;staging -d example.com -d www.example.com<br>volumes:<br>certbot-etc:<br>certbot-var:<br>web-root:<br>driver: local<br>driver_opts:<br>type: none<br>device: \/home\/helloapp\/<\/span><br><span class=\"has-inline-color has-vivid-cyan-blue-color\">o: bind<br>networks:<br>app-network:<br>driver: bridge<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>10) We can start our containers with docker-compose up, which will create and run our containers and services in the order we have specified. If our domain requests are successful, we will see the correct exit status in our output and the right certificates mounted in the \/etc\/letsencrypt\/live folder on the webserver container.<br><br>First build the image with the below command.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">Docker build -t helloapp .<\/span><\/p>\n\n\n\n<p>Now run the below command to create the services and run the containers.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">docker-compose up -d<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"697\" height=\"521\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image.png\" alt=\"\" class=\"wp-image-6339\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image.png 697w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-300x224.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-401x300.png 401w\" sizes=\"auto, (max-width: 697px) 100vw, 697px\" \/><\/a><\/figure>\n\n\n\n<p>11) Using <span class=\"has-inline-color has-vivid-cyan-blue-color\">docker-compose ps<\/span>, check the status of your services.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1002\" height=\"292\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image-1.png\" alt=\"\" class=\"wp-image-6340\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-1.png 1002w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-1-300x87.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-1-768x224.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-1-850x248.png 850w\" sizes=\"auto, (max-width: 1002px) 100vw, 1002px\" \/><\/a><\/figure>\n\n\n\n<p>12) If you want to check the service logs, execute the below command.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">docker-compose logs service_name<\/span><\/p>\n\n\n\n<p>13) You can now check that your credentials have been mounted to the webserver container with docker-compose exec<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">docker-compose exec webserver ls -la \/etc\/letsencrypt\/live<code><span class=\"has-inline-color has-vivid-cyan-blue-color\"><\/span><\/code><\/span><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"927\" height=\"144\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image-2.png\" alt=\"\" class=\"wp-image-6341\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-2.png 927w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-2-300x47.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-2-768x119.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-2-850x132.png 850w\" sizes=\"auto, (max-width: 927px) 100vw, 927px\" \/><\/a><\/figure>\n\n\n\n<p>14) Now that you know your request will be successful, you can edit the certbot service definition to remove the &#8211;staging flag. Open <span class=\"has-inline-color has-vivid-cyan-blue-color\">docker-compose.yml<\/span><br><span class=\"has-inline-color has-vivid-cyan-blue-color\">nano docker.compose.yml<\/span><\/p>\n\n\n\n<p>15) Find the section of the file with the certbot service definition, and replace the &#8211;staging flag in the command option with the &#8211;force-renewal flag, which will tell Certbot that you want to request a new certificate with the same domains as an existing certificate. The certbot service definition should now look like below.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"has-inline-color has-vivid-cyan-blue-color\">certbot:<br>image: certbot\/certbot<br>container_name: certbot<br>volumes:<br>&#8211; certbot-etc:\/etc\/letsencrypt<br>&#8211; certbot-var:\/var\/lib\/letsencrypt<br>&#8211; web-root:\/var\/www\/html<br>depends_on:<br>&#8211; webserver<br>command: certonly &#8211;webroot &#8211;webroot-path=\/var\/www\/html &#8211;email abc@gmail.com &#8211;agree-tos &#8211;no-eff-email &#8211;force-renewal -d dockertestings.pheonixsolutions.com<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>16) You can now run docker-compose up to recreate the certbot container and its relevant volumes. We will also include the &#8211;no-deps option to tell Compose that it can skip starting the webserver service, since it is already running.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">docker-compose up &#8211;force-recreate &#8211;no-deps certbot<\/span><\/p>\n\n\n\n<p>17) You will see output indicating that your certificate request was successful.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"229\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image-3-1024x229.png\" alt=\"\" class=\"wp-image-6342\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-3-1024x229.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-3-300x67.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-3-768x172.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-3-1536x344.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-3-850x190.png 850w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-3.png 1853w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>18) Now we will modify the webserver Configuration and Service Definition. First stop the webserver with the below command. Enabling SSL in our Nginx configuration will involve adding an HTTP redirect to HTTPS and specifying our SSL certificate and key locations. It will also involve specifying our Diffie-Hellman group, which we will use for perfect forward secrecy.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">docker-compose stop webserver<\/span><\/p>\n\n\n\n<p>19) Next, create a directory in your current project directory for your Diffie-Hellman key<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">mkdir dhparam<\/span><\/p>\n\n\n\n<p>20) Generate your key with the openssl command<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">sudo openssl dhparam -out \/home\/helloapp\/dhparam\/dhparam-2048.pem 2048<\/span><\/p>\n\n\n\n<p>It will take a few moments to generate the key.<\/p>\n\n\n\n<p>21) To add the relevant Diffie-Hellman and SSL information to your Nginx configuration, first remove the Nginx configuration file you created earlier.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">rm nginx-conf\/nginx.conf<\/span><\/p>\n\n\n\n<p>22) Again create config file.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">nano nginx-conf\/nginx.conf<\/span><\/p>\n\n\n\n<p>23) Add the following code to the file to redirect HTTP to HTTPS and to add SSL credentials, protocols, and security headers.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"has-inline-color has-vivid-cyan-blue-color\">server {<br>listen 80;<br>listen [::]:80;<br>server_name dockertestings.pheonixsolutions.com;<\/span><br><span class=\"has-inline-color has-vivid-cyan-blue-color\"><br>location ~ \/.well-known\/acme-challenge { allow all; root \/var\/www\/html; } location \/ { rewrite ^ https:\/\/$host$request_uri? permanent; }<br>}<br>server {<br>listen 443 ssl http2;<br>listen [::]:443 ssl http2;<br>server_name dockertestings.pheonixsolutions.com;<br><br>server_tokens off;<br><br>ssl_certificate \/etc\/letsencrypt\/live\/dockertestings.pheonixsolutions.com\/fullchain.pem; <br>ssl_certificate_key \/etc\/letsencrypt\/live\/dockertestings.pheonixsolutions.com\/privkey.pem;<br>ssl_buffer_size 8k; <br><br>ssl_dhparam \/etc\/ssl\/certs\/dhparam-2048.pem; <br><br>ssl_protocols TLSv1.2 TLSv1.1 TLSv1; <br><br>ssl_prefer_server_ciphers on; <br>ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5; <br><br>ssl_ecdh_curve secp384r1; <br><br>ssl_session_tickets off; <br><br>ssl_stapling on; ssl_stapling_verify on; <br><br>resolver 8.8.8.8; <br><br>location \/ <br>        { try_files $uri @nodejs; <br>} <br><br>location @nodejs { <br>proxy_pass http:\/\/dockertestings.pheonixsolutions.com:8080; <br>add_header X-Frame-Options &#8220;SAMEORIGIN&#8221; always;<br>add_header X-XSS-Protection &#8220;1; mode=block&#8221; always; <br>add_header X-Content-Type-Options &#8220;nosniff&#8221; always; <br>add_header Referrer-Policy &#8220;no-referrer-when-downgrade&#8221; always; <br>add_header Content-Security-Policy &#8220;default-src * data: &#8216;unsafe-eval&#8217; &#8216;unsafe-inline'&#8221; always;<br>#add_header Strict-Transport-Security &#8220;max-age=31536000; includeSubDomains; preload&#8221; always;<br># enable strict transport security only if you understand the implications <br>} <br>root \/var\/www\/html; <br>index index.html index.htm index.nginx-debian.html;<br>}<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>24)  Before recreating the webserver service, you will need to add a few things to the service definition in your docker-compose.yml file, including relevant port information for HTTPS and a Diffie-Hellman volume definition.<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">nano docker-compose.yml<\/span><\/p>\n\n\n\n<p>25) In the webserver service definition, add the following port mapping and the dhparam named volume. It will be like below.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"has-inline-color has-vivid-cyan-blue-color\">webserver:<br>image: nginx:mainline-alpine<br>container_name: webserver<br>restart: always<br>ports:<br>&#8211; &#8220;80:80&#8221;<br>&#8211; &#8220;443:443&#8221;<br>volumes:<br>&#8211; web-root:\/var\/www\/html<br>&#8211; .\/nginx-conf:\/etc\/nginx\/conf.d<br>&#8211; certbot-etc:\/etc\/letsencrypt<br>&#8211; certbot-var:\/var\/lib\/letsencrypt<br>&#8211; dhparam:\/etc\/ssl\/certs<br>depends_on:<br>&#8211; nodejs<br>networks:<br>&#8211; app-network<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Next, add the dhparam volume to your volumes definitions<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"has-inline-color has-vivid-cyan-blue-color\">volumes:<br>certbot-etc:<br>certbot-var:<br>web-root:<br>dhparam:<br>driver: local<br>driver_opts:<br>type: none<br>device: \/root\/helloapp\/dhparam\/<br>o: bind<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Now the complete docker-compose.yml file look like below.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"has-inline-color has-vivid-cyan-blue-color\">version: &#8216;3&#8217;<br><br><br>services:<br>nodejs:<br>build:<br>context: .<br>dockerfile: Dockerfile<br>image: helloapp<br>container_name: helloapp<br>ports:<br>&#8211; &#8220;8080:8080&#8221;<br>restart: always<br>networks:<br>&#8211; app-network<br><br><br>webserver:<br>image: nginx:mainline-alpine<br>container_name: webserver<br>restart: always<br>ports:<br>&#8211; &#8220;80:80&#8221;<br>&#8211; &#8220;443:443&#8221;<br>volumes:<br>&#8211; web-root:\/var\/www\/html<br>&#8211; .\/nginx-conf:\/etc\/nginx\/conf.d<br>&#8211; certbot-etc:\/etc\/letsencrypt<br>&#8211; certbot-var:\/var\/lib\/letsencrypt<br>&#8211; dhparam:\/etc\/ssl\/certs<br>depends_on:<br>&#8211; nodejs<br>networks:<br>&#8211; app-network<br><br><br>certbot:<br>image: certbot\/certbot<br>container_name: certbot<br>volumes:<br>&#8211; certbot-etc:\/etc\/letsencrypt<br>&#8211; certbot-var:\/var\/lib\/letsencrypt<br>&#8211; web-root:\/var\/www\/html<br>depends_on:<br>&#8211; webserver<br>command: certonly &#8211;webroot &#8211;webroot-path=\/var\/www\/html &#8211;email abc@gmail.com &#8211;agree-tos &#8211;no-eff-email &#8211;force-renewal -d dockertestings.pheonixsolutions.com<br><br><br>volumes:<br>certbot-etc:<br>certbot-var:<br>web-root:<br>dhparam:<br>driver: local<br>driver_opts:<br>type: none<br>device: \/root\/helloapp\/dhparam\/<br>o: bind<br><br><br>networks:<br>app-network:<br>driver: bridge<\/span><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>26) Recreate the webserver service with the below command<br><span class=\"has-inline-color has-vivid-cyan-blue-color\">docker-compose up -d &#8211;force-recreate &#8211;no-deps webserver<\/span><\/p>\n\n\n\n<p>27) Check your services with docker-compose ps. It should look like below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"100\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image-4-1024x100.png\" alt=\"\" class=\"wp-image-6343\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-4-1024x100.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-4-300x29.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-4-768x75.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-4-850x83.png 850w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-4.png 1147w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>28) Finally, you can visit your domain to ensure that everything is working as expected. Navigate your browser to <a href=\"https:\/\/dockertesting.pheonixsolutions.com\/\">https:\/\/example.com<\/a>. Replace with your own domain and check.<\/p>\n\n\n\n<p>It should look like below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"737\" height=\"313\" src=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image-5.png\" alt=\"\" class=\"wp-image-6344\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-5.png 737w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-5-300x127.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2021\/06\/image-5-706x300.png 706w\" sizes=\"auto, (max-width: 737px) 100vw, 737px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>1)To achieve the above, first we need to install docker. Please follow the below link to install docker.https:\/\/docs.docker.com\/engine\/install\/ubuntu\/#install-using-the-repository 2) Create a sample application. Create a directory called &#8220;helloapp&#8221;. Create file index.js.mkdir helloappcd helloappvi index.js 3) Copy and paste the below content. const express = require(&#8220;express&#8221;);const app = express();app.get(&#8220;\/&#8221;, (req, res)&hellip; <a href=\"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/\" class=\"more-link read-more\" rel=\"bookmark\">Continue Reading <span class=\"screen-reader-text\">Deploy a sample app with Docker over SSL<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[303,306,518],"tags":[874,875,277],"class_list":{"0":"post-6338","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-devops","7":"category-docker","8":"category-docker-2","9":"tag-sample-app","10":"tag-sample-app-with-docker-over-ssl","11":"tag-ssl","12":"h-entry","14":"h-as-article"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pheonix Solutions - We Empower Your Business Growth<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pheonix Solutions - We Empower Your Business Growth\" \/>\n<meta property=\"og:description\" content=\"1)To achieve the above, first we need to install docker. Please follow the below link to install docker.https:\/\/docs.docker.com\/engine\/install\/ubuntu\/#install-using-the-repository 2) Create a sample application. Create a directory called &#8220;helloapp&#8221;. Create file index.js.mkdir helloappcd helloappvi index.js 3) Copy and paste the below content. const express = require(&#8220;express&#8221;);const app = express();app.get(&#8220;\/&#8221;, (req, res)&hellip; Continue Reading Deploy a sample app with Docker over SSL\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/\" \/>\n<meta property=\"og:site_name\" content=\"PHEONIXSOLUTIONS\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-19T15:07:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-19T16:03:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pheonixsolution\" \/>\n<meta name=\"twitter:site\" content=\"@pheonixsolution\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/0ffa33d73c869faec2d50e79c24e3503\"},\"headline\":\"Deploy a sample app with Docker over SSL\",\"datePublished\":\"2021-06-19T15:07:17+00:00\",\"dateModified\":\"2021-06-19T16:03:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/\"},\"wordCount\":1404,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.pheonixsolutions.com\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/image.png\",\"keywords\":[\"sample app\",\"sample app with docker over ssl\",\"ssl\"],\"articleSection\":[\"Devops\",\"Docker\",\"Docker\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/\",\"name\":\"Pheonix Solutions - We Empower Your Business Growth\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.pheonixsolutions.com\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/image.png\",\"datePublished\":\"2021-06-19T15:07:17+00:00\",\"dateModified\":\"2021-06-19T16:03:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/#primaryimage\",\"url\":\"https:\\\/\\\/blog.pheonixsolutions.com\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/image.png\",\"contentUrl\":\"https:\\\/\\\/blog.pheonixsolutions.com\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/image.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/deploy-a-sample-app-with-docker-over-ssl\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Deploy a sample app with Docker over SSL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\",\"name\":\"Pheonix Solutions\",\"description\":\"We Empower Your Business Growth\",\"publisher\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\",\"name\":\"PheonixSolutions\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/12\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/12\\\/logo.png\",\"width\":454,\"height\":300,\"caption\":\"PheonixSolutions\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/PheonixSolutions-209942982759387\\\/\",\"https:\\\/\\\/x.com\\\/pheonixsolution\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/0ffa33d73c869faec2d50e79c24e3503\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"http:\\\/\\\/blog.pheonixsolutions.com\"],\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pheonix Solutions - We Empower Your Business Growth","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/","og_locale":"en_US","og_type":"article","og_title":"Pheonix Solutions - We Empower Your Business Growth","og_description":"1)To achieve the above, first we need to install docker. Please follow the below link to install docker.https:\/\/docs.docker.com\/engine\/install\/ubuntu\/#install-using-the-repository 2) Create a sample application. Create a directory called &#8220;helloapp&#8221;. Create file index.js.mkdir helloappcd helloappvi index.js 3) Copy and paste the below content. const express = require(&#8220;express&#8221;);const app = express();app.get(&#8220;\/&#8221;, (req, res)&hellip; Continue Reading Deploy a sample app with Docker over SSL","og_url":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/","og_site_name":"PHEONIXSOLUTIONS","article_publisher":"https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/","article_published_time":"2021-06-19T15:07:17+00:00","article_modified_time":"2021-06-19T16:03:20+00:00","og_image":[{"url":"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image.png","type":"","width":"","height":""}],"author":"admin","twitter_card":"summary_large_image","twitter_creator":"@pheonixsolution","twitter_site":"@pheonixsolution","twitter_misc":{"Written by":"admin","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/#article","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/"},"author":{"name":"admin","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/person\/0ffa33d73c869faec2d50e79c24e3503"},"headline":"Deploy a sample app with Docker over SSL","datePublished":"2021-06-19T15:07:17+00:00","dateModified":"2021-06-19T16:03:20+00:00","mainEntityOfPage":{"@id":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/"},"wordCount":1404,"commentCount":0,"publisher":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#organization"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image.png","keywords":["sample app","sample app with docker over ssl","ssl"],"articleSection":["Devops","Docker","Docker"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/","url":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/","name":"Pheonix Solutions - We Empower Your Business Growth","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/#primaryimage"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image.png","datePublished":"2021-06-19T15:07:17+00:00","dateModified":"2021-06-19T16:03:20+00:00","breadcrumb":{"@id":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/#primaryimage","url":"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image.png","contentUrl":"https:\/\/blog.pheonixsolutions.com\/wp-content\/uploads\/2021\/06\/image.png"},{"@type":"BreadcrumbList","@id":"https:\/\/pheonixsolutions.com\/blog\/deploy-a-sample-app-with-docker-over-ssl\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pheonixsolutions.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Deploy a sample app with Docker over SSL"}]},{"@type":"WebSite","@id":"https:\/\/pheonixsolutions.com\/blog\/#website","url":"https:\/\/pheonixsolutions.com\/blog\/","name":"Pheonix Solutions","description":"We Empower Your Business Growth","publisher":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pheonixsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/pheonixsolutions.com\/blog\/#organization","name":"PheonixSolutions","url":"https:\/\/pheonixsolutions.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/12\/logo.png","contentUrl":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/12\/logo.png","width":454,"height":300,"caption":"PheonixSolutions"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/","https:\/\/x.com\/pheonixsolution"]},{"@type":"Person","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/person\/0ffa33d73c869faec2d50e79c24e3503","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g","caption":"admin"},"sameAs":["http:\/\/blog.pheonixsolutions.com"],"url":"https:\/\/pheonixsolutions.com\/blog\/author\/admin\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7F4uM-1Ee","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=6338"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6338\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=6338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=6338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=6338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}