{"id":1399,"date":"2017-04-18T15:34:33","date_gmt":"2017-04-18T19:34:33","guid":{"rendered":"http:\/\/www.xavignu.com\/?p=1399"},"modified":"2017-04-18T15:34:33","modified_gmt":"2017-04-18T19:34:33","slug":"run-python-script-with-docker","status":"publish","type":"post","link":"https:\/\/www.xavignu.com\/?p=1399","title":{"rendered":"Run python script with docker"},"content":{"rendered":"<p>So I started playing with <a href=\"https:\/\/www.docker.com\/\" target=\"_blank\">docker<\/a> and asked myself whether it would be possible to run a python script with docker. Well, answer is yes. Example of the script below.<\/p>\n<p>[python]<br \/>\n#!\/usr\/bin\/python<\/p>\n<p>import sys<br \/>\nprint &#8220;Running script!!&#8221;<br \/>\nprint sys.version_info<br \/>\n[\/python]<\/p>\n<p>Execution below:<\/p>\n<pre id=\"terminal\">docker run -it --rm --name pythonscript -v \"$PWD\":\/usr\/src\/myapp -w \/usr\/src\/myapp python:2 python script.py\r\nRunning script!!\r\nsys.version_info(major=2, minor=7, micro=13, releaselevel='final', serial=0)\r\n<\/pre>\n<p>References:<br \/>\n<a href=\"https:\/\/hub.docker.com\/_\/python\/\" target=\"_blank\">Docker documentation<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I started playing with docker and asked myself whether it would be possible to run a python script with docker. Well, answer is yes. Example of the script below. [python] #!\/usr\/bin\/python import sys print &#8220;Running script!!&#8221; print sys.version_info [\/python] Execution below: docker run -it &#8211;rm &#8211;name pythonscript -v &#8220;$PWD&#8221;:\/usr\/src\/myapp -w \/usr\/src\/myapp python:2 python script.py [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[3],"tags":[83,6,70],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pTQgt-mz","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/1399"}],"collection":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1399"}],"version-history":[{"count":3,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/1399\/revisions"}],"predecessor-version":[{"id":1402,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=\/wp\/v2\/posts\/1399\/revisions\/1402"}],"wp:attachment":[{"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xavignu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}