{"id":1871,"date":"2017-04-25T17:03:18","date_gmt":"2017-04-25T15:03:18","guid":{"rendered":"http:\/\/blog.rabahi.net\/?page_id=1871"},"modified":"2017-04-25T17:06:55","modified_gmt":"2017-04-25T15:06:55","slug":"docker-use-official-image","status":"publish","type":"page","link":"https:\/\/blog.rabahi.net\/?page_id=1871","title":{"rendered":"Docker use official image"},"content":{"rendered":"<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#Step1_search_the_Docker_Hub_for_8216centos8217_image\"><span class=\"toc_number toc_depth_1\">1<\/span> Step1 : search the Docker Hub for &#8216;centos&#8217; image<\/a><\/li><li><a href=\"#Step2_download_official_8216centos8217_image\"><span class=\"toc_number toc_depth_1\">2<\/span> Step2 : download official &#8216;centos&#8217; image<\/a><\/li><li><a href=\"#Step3_Run_a_container_using_the_8216centos8217_image\"><span class=\"toc_number toc_depth_1\">3<\/span> Step3 : Run a container using the &#8216;centos&#8217; image<\/a><\/li><li><a href=\"#Step4_Get_an_interactive_shell_on_the_8216centos8217_container\"><span class=\"toc_number toc_depth_1\">4<\/span> Step4 : Get an interactive shell on the &#8216;centos&#8217; container<\/a><\/li><li><a href=\"#Step5_create_a_new_container_with_custom_packages\"><span class=\"toc_number toc_depth_1\">5<\/span> Step5: create a new container with custom packages<\/a><\/li><li><a href=\"#Step6_That8217s_it_8217\"><span class=\"toc_number toc_depth_1\">6<\/span> Step6: That&#8217;s it !&#8217;<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Step1_search_the_Docker_Hub_for_8216centos8217_image\">Step1 : search the Docker Hub for &#8216;centos&#8217; image<\/span><\/h2>\n<pre lang=\"bash\">\r\ndocker search centos\r\n<\/pre>\n<h2><span id=\"Step2_download_official_8216centos8217_image\">Step2 : download official &#8216;centos&#8217; image<\/span><\/h2>\n<pre lang=\"bash\">\r\ndocker pull centos\r\n<\/pre>\n<h2><span id=\"Step3_Run_a_container_using_the_8216centos8217_image\">Step3 : Run a container using the &#8216;centos&#8217; image<\/span><\/h2>\n<pre lang=\"bash\">\r\ndocker run centos\r\n<\/pre>\n<h2><span id=\"Step4_Get_an_interactive_shell_on_the_8216centos8217_container\">Step4 : Get an interactive shell on the &#8216;centos&#8217; container<\/span><\/h2>\n<pre lang=\"bash\">\r\ndocker run -it centos\r\n<\/pre>\n<h2><span id=\"Step5_create_a_new_container_with_custom_packages\">Step5: create a new container with custom packages<\/span><\/h2>\n<p>First make a change<\/p>\n<pre lang=\"bash\">\r\n[root@82dd093e740d ~]# yum install httpd\r\n[root@82dd093e740d ~]# exit\r\n<\/pre>\n<p>Then commit<\/p>\n<pre lang=\"bash\">\r\ndocker commit -m \"pretty commit message\" -a \"author name\" 82dd093e740d centos-with-httpd\r\n<\/pre>\n<p>Note: 82dd093e740d is the container-id (we can got it using &#8216;docker ps&#8217; the the container runs).<\/p>\n<h2><span id=\"Step6_That8217s_it_8217\">Step6: That&#8217;s it !&#8217;<\/span><\/h2>\n<pre lang=\"bash\">\r\ndocker images\r\n\r\n[root@localhost opt]# docker images\r\nREPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE\r\ncentos-with-httpd           latest              c5135e3e3ee5        40 minutes ago      313MB\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Contents1 Step1 : search the Docker Hub for &#8216;centos&#8217; image2 Step2 : download official &#8216;centos&#8217; image3 Step3 : Run a container using the &#8216;centos&#8217; image4 Step4 : Get an interactive shell on the &#8216;centos&#8217; container5 Step5: create a new container with custom packages6 Step6: That&#8217;s it !&#8217; Step1 : search the Docker Hub for &#8216;centos&#8217; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1857,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1871","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1871"}],"version-history":[{"count":2,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1871\/revisions"}],"predecessor-version":[{"id":1880,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1871\/revisions\/1880"}],"up":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1857"}],"wp:attachment":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}