{"id":471,"date":"2016-02-23T11:51:34","date_gmt":"2016-02-23T11:51:34","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2016\/02\/23\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/"},"modified":"2021-02-27T09:49:44","modified_gmt":"2021-02-27T09:49:44","slug":"how-to-get-bash-or-ssh-into-a-running-container-in-background-mode","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/","title":{"rendered":"How to get bash or ssh into a running container in background mode?"},"content":{"rendered":"<div><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3196 size-full aligncenter\" src=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2016\/02\/bash-or-ssh-into-a-running-1-1.png\" alt=\"bash-or-ssh-into-a-running-container\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2016\/02\/bash-or-ssh-into-a-running-1-1.png 600w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2016\/02\/bash-or-ssh-into-a-running-1-1-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/div>\n<div><strong>How to get bash or ssh into a running container in background mode?<\/strong><\/div>\n<div><\/div>\n<div><strong>Step 1: First of all, try to find your active container by running<\/strong><\/div>\n<div># docker ps<\/div>\n<div>or<\/div>\n<div># docker ps -a<\/div>\n<div><\/div>\n<div><strong>Step 2: If the container is not running,<\/strong><\/div>\n<div># docker start your_id<\/div>\n<div><\/div>\n<div><strong>Step 3: If we use attach we can use only one instance of shell.<\/strong><\/div>\n<div># sudo docker attach 665b4a1e17b6 #by ID<\/div>\n<div>or<\/div>\n<div># sudo docker attach loving_heisenberg #by Name<\/div>\n<div><\/div>\n<div>If we want open new terminal with new instance of container&#8217;s shell, we just need run the following:<\/div>\n<div># sudo docker exec -i -t 2e56ad1705b1 \/bin\/bash #by ID<\/div>\n<div>or<\/div>\n<div># sudo docker exec -i -t loving_heisenberg \/bin\/bash #by Name<\/div>\n<div># root@665b4a1e17b6:\/#<\/div>\n<div><\/div>\n<div><strong>Step 4: To exit bash without leaving bash running in a rogue process<\/strong><\/div>\n<div># exit<\/div>\n<div><\/div>\n<div><strong>Notes:<\/strong><\/div>\n<div>A reminder for boot2docker users: remove sudo<\/div>\n<div>If you are using docker in Linux, you will have to use sudo along with docker commands.<\/div>\n<div>You should try not to run commands as sudo, rather add your user to the docker group and just run normally.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>How to get bash or ssh into a running container in background mode? Step 1: First of all, try to [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":3196,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[546],"tags":[1196,137,1194,567,545,321,1195,896,1197],"class_list":["post-471","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-containers","tag-background","tag-bash","tag-container","tag-docker","tag-how","tag-mode","tag-running-container","tag-ssh","tag-ssh-into-a-container"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to get bash or ssh into a running container in background mode? - scmGalaxy<\/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:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to get bash or ssh into a running container in background mode? - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"How to get bash or ssh into a running container in background mode? Step 1: First of all, try to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-23T11:51:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-02-27T09:49:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2016\/02\/bash-or-ssh-into-a-running-1-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"scmgalaxy K\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"scmgalaxy K\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/\"},\"author\":{\"name\":\"scmgalaxy K\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"headline\":\"How to get bash or ssh into a running container in background mode?\",\"datePublished\":\"2016-02-23T11:51:34+00:00\",\"dateModified\":\"2021-02-27T09:49:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/\"},\"wordCount\":193,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/bash-or-ssh-into-a-running-1-1.png\",\"keywords\":[\"Background\",\"Bash\",\"Container\",\"Docker\",\"How\",\"mode\",\"Running container\",\"SSH\",\"SSH into a Container\"],\"articleSection\":[\"CONTAINERS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/\",\"name\":\"How to get bash or ssh into a running container in background mode? - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/bash-or-ssh-into-a-running-1-1.png\",\"datePublished\":\"2016-02-23T11:51:34+00:00\",\"dateModified\":\"2021-02-27T09:49:44+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/bash-or-ssh-into-a-running-1-1.png\",\"contentUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2016\\\/02\\\/bash-or-ssh-into-a-running-1-1.png\",\"width\":600,\"height\":400,\"caption\":\"bash-or-ssh-into-a-running-container\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to get bash or ssh into a running container in background mode?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\",\"name\":\"scmgalaxy K\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"caption\":\"scmgalaxy K\"},\"sameAs\":[\"http:\\\/\\\/www.DevOpsSchool.com\"],\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/scmgalaxy\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to get bash or ssh into a running container in background mode? - scmGalaxy","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:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/","og_locale":"en_US","og_type":"article","og_title":"How to get bash or ssh into a running container in background mode? - scmGalaxy","og_description":"How to get bash or ssh into a running container in background mode? Step 1: First of all, try to [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/","og_site_name":"scmGalaxy","article_published_time":"2016-02-23T11:51:34+00:00","article_modified_time":"2021-02-27T09:49:44+00:00","og_image":[{"width":600,"height":400,"url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2016\/02\/bash-or-ssh-into-a-running-1-1.png","type":"image\/png"}],"author":"scmgalaxy K","twitter_card":"summary_large_image","twitter_misc":{"Written by":"scmgalaxy K","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/"},"author":{"name":"scmgalaxy K","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"headline":"How to get bash or ssh into a running container in background mode?","datePublished":"2016-02-23T11:51:34+00:00","dateModified":"2021-02-27T09:49:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/"},"wordCount":193,"commentCount":0,"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2016\/02\/bash-or-ssh-into-a-running-1-1.png","keywords":["Background","Bash","Container","Docker","How","mode","Running container","SSH","SSH into a Container"],"articleSection":["CONTAINERS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/","name":"How to get bash or ssh into a running container in background mode? - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/#primaryimage"},"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2016\/02\/bash-or-ssh-into-a-running-1-1.png","datePublished":"2016-02-23T11:51:34+00:00","dateModified":"2021-02-27T09:49:44+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/#primaryimage","url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2016\/02\/bash-or-ssh-into-a-running-1-1.png","contentUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2016\/02\/bash-or-ssh-into-a-running-1-1.png","width":600,"height":400,"caption":"bash-or-ssh-into-a-running-container"},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"How to get bash or ssh into a running container in background mode?"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102","name":"scmgalaxy K","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","caption":"scmgalaxy K"},"sameAs":["http:\/\/www.DevOpsSchool.com"],"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/scmgalaxy\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=471"}],"version-history":[{"count":3,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/471\/revisions"}],"predecessor-version":[{"id":3274,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/471\/revisions\/3274"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media\/3196"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}