{"id":3210,"date":"2018-12-30T10:33:18","date_gmt":"2018-12-30T05:03:18","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=3210"},"modified":"2019-01-04T09:24:16","modified_gmt":"2019-01-04T03:54:16","slug":"how-to-create-docker-container","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-create-docker-container\/","title":{"rendered":"How to create docker container"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">How to create docker container <\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Date posted : 28\/12\/2018<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What is Docker ?<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Docker is a containerization platform that packages your application and all its dependencies together in the form of a docker container to ensure that your application works seamlessly in any environment.<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What is Container ?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Docker Container is a standardized unit which can be created on the fly to deploy a particular application or environment. It could be an Ubuntu container, CentOs container, etc. to full-fill the requirement from an operating system point of view. Also, it could be an application oriented container like CakePHP container or a Tomcat-Ubuntu container etc.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Prerequisites<\/h4>\n\n\n\n<ol class=\"wp-block-list\"><li>Install Docker and enable the service.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-pheonix-solutions\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"WIjpbHpQgF\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-install-docker-in-centos-7\/\">How to install Docker in Centos 7<\/a><\/blockquote><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;How to install Docker in Centos 7&#8221; &#8212; PHEONIXSOLUTIONS\" src=\"https:\/\/pheonixsolutions.com\/blog\/how-to-install-docker-in-centos-7\/embed\/#?secret=xUQ9PVq7OW#?secret=WIjpbHpQgF\" data-secret=\"WIjpbHpQgF\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><figcaption>This above blog will helpful for installing Docker in centos 7 linux platform.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">2. Check the disk- space availability of our system.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# df -h \n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">3.  Check the Process status of Docker.[Running status of Docker] <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker ps\n\nCONTAINER ID        IMAGE               COMMAND             CREATED                                                                                                                          STATUS              PORTS               NAMES\n\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Create Docker Images and Containerization.<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1<\/strong> : . Pull your required Os( 1<sup>st<\/sup> centos) for Docker Images. [Pull images from docker Hub]<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker pull centos\nlatest: Pulling from library\/centos\na02a4930cb5d: Pull complete\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Status: Downloaded newer image for centos:latest<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2<\/strong> :  Check the Docker image whether it is pulled.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker images\nREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\ncentos              latest              1e1148e4cc2c        13 days ago         202MB\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3<\/strong>. Pull your required Os( 2<sup>nd<\/sup> Ubuntu) for Docker Images. [Pull images from Docker images]<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker pull ubuntu\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Status: Downloaded newer image for ubuntu:latest<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 4<\/strong>. Check the Docker images to know Image id and whether it is pulled. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n docker images\nREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\ncentos              latest              1e1148e4cc2c        13 days ago         202MB\nubuntu              latest              93fd78260bd1        4 weeks ago         86.2MB\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 5:<\/strong> Run a docker in detach mode, to create a container in your own names. (Note: for Centos)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here, we have created a container in name of XYZ, replace of it in your convenience.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker run -itd --name=xyz  centos:latest \/bin\/bash\n667db752093100944df883d799a8d4f09564669f061362e614364d4a319e8529\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 6:<\/strong> Check the Running status  of the Docker .<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker ps\nCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES\n667db7520931        centos:latest       &quot;\/bin\/bash&quot;         10 seconds ago      Up 9 seconds                     xyz\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 7:<\/strong>Run a docker in detach mode, to create a container in your own names. (Note: for Ubuntu)<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n docker run -itd --name=abc  ubuntu:latest \/bin\/bash 95dad75e0c6ccd1330053d0e5aff19b42fd67d22dcb7b52d62e503a79624a11b \n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 8 <\/strong>: Check the Docker Running status of it with names, container Id, Image, status and ports. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker ps\nCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES\n95dad75e0c6c        ubuntu:latest       &quot;\/bin\/bash&quot;         5 seconds ago       Up 4 seconds                            abc\n667db7520931        centos:latest       &quot;\/bin\/bash&quot;         58 seconds ago      Up 57 seconds                           xyz\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 9:<\/strong>Execute the running container .( for XYZ , centos). It will enter in to a container.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker exec -it xyz \/bin\/bash\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Now you are Inside the container.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 10<\/strong> : Check the os version in etc directory.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncat \/etc\/os-release\nNAME=&quot;CentOS Linux&quot;\nVERSION=&quot;7 (Core)&quot;\nID=&quot;centos&quot;\nID_LIKE=&quot;rhel fedora&quot;\nVERSION_ID=&quot;7&quot;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 11:<\/strong> Exit the container.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n #Exit\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Now check the running container progress once.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# docker ps\nCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES\n95dad75e0c6c        ubuntu: latest       &quot;\/bin\/bash&quot;         9 minutes ago       Up 9 minutes                            abc\n667db7520931        centos: latest       &quot;\/bin\/bash&quot;         10 minutes ago      Up 10 minutes                           xyz\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 12: <\/strong>Execute the running container .( for abc container, Ubuntu). It will enter in to a container.  <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker exec -it abc \/bin\/bash\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 13: <\/strong>Check the os version in etc directory.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# cat \/etc\/os-release\nNAME=&quot;Ubuntu&quot;\nVERSION=&quot;18.04.1 LTS (Bionic Beaver)&quot;\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 14 <\/strong>:  Exit the container <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code brush: plain; notranslate\"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# Exit\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">This article helps you to guide in creating a Docker image and container in a easy manner.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to create docker container Date posted : 28\/12\/2018 What is Docker ? Docker is a containerization platform that packages [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_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":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1020],"tags":[520,519],"class_list":["post-3210","post","type-post","status-publish","format-standard","hentry","category-containers-kubernetes","tag-docker-container","tag-docker-image","psol-cat-containers-kubernetes"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-PM","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3210","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=3210"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3210\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}