{"id":1868,"date":"2017-04-25T17:02:14","date_gmt":"2017-04-25T15:02:14","guid":{"rendered":"http:\/\/blog.rabahi.net\/?page_id=1868"},"modified":"2017-04-25T17:07:20","modified_gmt":"2017-04-25T15:07:20","slug":"docker-build-app","status":"publish","type":"page","link":"https:\/\/blog.rabahi.net\/?page_id=1868","title":{"rendered":"Docker build APP"},"content":{"rendered":"<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#First_create_the_file_names_8216Dockerfile8217\"><span class=\"toc_number toc_depth_1\">1<\/span> First create the file names &#8216;Dockerfile&#8217;<\/a><\/li><li><a href=\"#Build_new_container\"><span class=\"toc_number toc_depth_1\">2<\/span> Build new container<\/a><\/li><li><a href=\"#Now_you_can_access_to_it\"><span class=\"toc_number toc_depth_1\">3<\/span> Now you can access to it<\/a><\/li><li><a href=\"#If_you_can_to_update_the_MYENVVAR_value\"><span class=\"toc_number toc_depth_1\">4<\/span> If you can to update the MYENVVAR value<\/a><\/li><\/ul><\/div>\n<h2><span id=\"First_create_the_file_names_8216Dockerfile8217\">First create the file names &#8216;Dockerfile&#8217;<\/span><\/h2>\n<pre>\r\n# Use an official image of centos\r\nFROM centos\r\n\r\n# Set the working directory to \/opt\/docker\r\nWORKDIR \/opt\/docker\r\n\r\n# Copy the current directory contents into the container at \/opt\/docker\r\nADD . \/opt\/docker\r\n\r\n# Install any needed packages\r\nRUN yum -y install epel-release\r\n\r\n# Define environment variable\r\nENV MYENVVAR my-env-value\r\n\r\n# Run shell when the container launches\r\nCMD [\"\/bin\/bash\"]\r\n<\/pre>\n<h2><span id=\"Build_new_container\">Build new container<\/span><\/h2>\n<pre lang=\"bash\">\r\ndocker build -t newcontainername .\r\n<\/pre>\n<h2><span id=\"Now_you_can_access_to_it\">Now you can access to it<\/span><\/h2>\n<pre lang=\"bash\">\r\ndocker run -it newcontainername\r\n<\/pre>\n<h2><span id=\"If_you_can_to_update_the_MYENVVAR_value\">If you can to update the MYENVVAR value<\/span><\/h2>\n<pre lang=\"bash\">\r\ndocker run -e MYENVVAR='new value' -it newcontainername\r\n\r\n[root@dcf332ea87ae docker]# echo $MYENVVAR\r\nnew value\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Contents1 First create the file names &#8216;Dockerfile&#8217;2 Build new container3 Now you can access to it4 If you can to update the MYENVVAR value First create the file names &#8216;Dockerfile&#8217; # Use an official image of centos FROM centos # Set the working directory to \/opt\/docker WORKDIR \/opt\/docker # Copy the current directory contents into [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1857,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1868","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1868","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=1868"}],"version-history":[{"count":2,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1868\/revisions"}],"predecessor-version":[{"id":1881,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1868\/revisions\/1881"}],"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=1868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}