TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Docker containers should not run an SSH server

125 pointsby davidkellisalmost 11 years ago

14 comments

rdtscalmost 11 years ago
What is the general pattern of usage with Docker containers? Are they supposed to isolate just one application and do IO via a networks socket?<p>It used to be you ran everything on a real server. Then it moved to VMs in the cloud. So spawning and managing VM was the the new thing to with a large IaaS,PaaS,...aaS industry around it.<p>The product would consist of one or multiple VMs. All possibly running multiple applications as different processes.<p>Then I guess inter-dependencies between applications and OS versions got to be complicated, so the idea was that each application should run in its own lightweight VM (with LXC as long as they share the same base OS kernel at least).<p>Isn&#x27;t this just pushing the problems into managing dependencies between more little VMs while also constraining the architecture? It increases the difficulty of synchronizing 10 or 20 separate isolated applications start,upgrade,fail. Maybe all that living on yet another VM guest machine (so conceptually having 2 virtualization levels). Handling more complicated network setup (bridging, firewall rules at multiple levels). Handling effects of disk and other subsystem interacting with each other in strange, sometimes sub-optimal ways.<p>One idea was that ok, this is good for security. One can build secure containers. But doesn&#x27;t SELinux do that better? It even has a multi-level security mode. It sure is complicated but it is used.
评论 #7950824 未加载
opendaisalmost 11 years ago
I think the core flaw with the &quot;no SSHD in Docker, ever&quot; reasoning is it makes a number of assumptions.<p>To me, for my use, Docker is really a lightweight role-based VM I can put on a provisioned host of some kind [another VM, dedicated server]. In other words, its a really simple way to deploy X identical instances of an entire service&#x2F;application. If <i>any</i> component in that instance of the application is non functional the container is dead and you route requests to a different container.<p>The problem with the &quot;one process per Docker instance&quot; logic is you need a great deal more service discovery logic as a result. There are a bunch of projects&#x2F;methods to simplify this but at the end of the day it adds complexity to operations. Instead of a single health check to monitor, you have X containers to monitor. You have X containers to discover, etc. Sure, this lets you get out of running Supervisor and SSH on a Docker container...but I think it adds alot of application complexity that you can avoid 90% of the time.<p>SOA makes sense when you have a large deployment but if you are deploying to a cluster of 5 machines...its overkill. Many [likely the majority] of projects are at the scale of a basic cluster for redundancy.
评论 #7950913 未加载
评论 #7950976 未加载
contingenciesalmost 11 years ago
Hrrm. I want to agree, but as far as containers go outside of purely docker, I just don&#x27;t buy these arguments.<p>It makes perfect sense to use industry standard, encrypted communications with proven cryptography when creating vast numbers of systems. Yes, you don&#x27;t have to. No, that doesn&#x27;t mean it&#x27;s a bad idea.<p>I&#x27;m not sure why things would be any different with docker, and after reading the article I&#x27;m unconvinced. If you want to be locked in to docker&#x27;s APIs, so be it. If you want to be free of them and integrate in other ways, such as proven, portable, secure methods like SSH, that&#x27;s fine too.<p>If a management task as simple as deploying a key is so hard in docker (couldn&#x27;t you just bind-mount a read only <i>.ssh</i> dir?), maybe you should consider alternative methods of container instantiation.<p>I don&#x27;t see how granting access to the host is a cleaner architecture... from a security standpoint, it seems the opposite.
评论 #7950977 未加载
评论 #7951003 未加载
CraigJPerryalmost 11 years ago
I don&#x27;t get it. What&#x27;s wrong with putting my SSH public key in the image?<p>Tbh I&#x27;d pay more attention to host key regeneration! Easily overlooked.<p>Until there&#x27;s better investigation tooling available, sshd seems a fairly sensible approach.<p>MAC &#x2F; SELinux prevents many other poke-inside techniques on enterprise platforms
评论 #7950686 未加载
评论 #7950843 未加载
FooBarWidgetalmost 11 years ago
I am the author of baseimage-docker (<a href="http://phusion.github.io/baseimage-docker/" rel="nofollow">http:&#x2F;&#x2F;phusion.github.io&#x2F;baseimage-docker&#x2F;</a>) and I work at Phusion. I have the feeling that Jerome wrote this article mainly in response to the fact that baseimage-docker encourages using SSH as a way to login to the container. I believe that the ability to login to the container is very important. Depending on how you architect your container, you might not have to, but I believe that it&#x27;s always good to have the <i>ability</i> to, even if only as a last resort method.<p>I had a pleasant conversation with Jerome quite a while ago about SSH and what the &quot;right&quot; way is to login to a Docker container. We were not able to find consensus, but Jerome is a brilliant guy and his reasons were sound. For some time, I considered using lxc-attach to replace the role of SSH. Unfortunately, a few weeks later, Docker 0.9 came out and no longer used LXC as the default backend, and so suddenly lxc-attach stopped working. We decided to stick with SSH until there&#x27;s a better way. Solomon Shykes told us that they have plans to introduce an lxc-attach-like tool in Docker core. Unfortunately, as of Docker 1.0.1, this feature still hasn&#x27;t arrived.<p>Now, Jerome is advocating nsenter. There is currently an ongoing discussion on the baseimage-docker bug tracker about replacing SSH with nsenter: <a href="https://github.com/phusion/baseimage-docker/issues/102" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;phusion&#x2F;baseimage-docker&#x2F;issues&#x2F;102</a><p>But leaving all of that aside, we regularly get told by people that Baseimage-docker &quot;misses the point&quot; of Docker. But what is the point of Docker? Some people, including Jerome, believe it&#x27;s all about microservices and running one process in a container.<p>We take a more balanced, nuanced view. We believe that Docker should be regarded as a flexible tool, that can be mended into whatever you want. You <i>can</i> make single-process microservices, if you want to and if you believe that&#x27;s the right choice for you. Or you can choose to make multi-process microservices, if that makes sense. Or you can choose to treat Docker like a lightweight VM. We believe that all of those choices are correct. We don&#x27;t believe that one should ONLY use Docker to build microservices, especially because Microservices Are Not A Free Lunch (<a href="http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html" rel="nofollow">http:&#x2F;&#x2F;highscalability.com&#x2F;blog&#x2F;2014&#x2F;4&#x2F;8&#x2F;microservices-not-a...</a>).<p>Baseimage-docker is about <i>enabling users</i> to do whatever they want to. It&#x27;s about choice. It&#x27;s not about cargo-culting everything into a single philosophy. This is why Baseimage-docker is extremely small and minimalist (only 6 MB memory over), flexible and thoroughly documented. Baseimage-docker is <i>not</i> about advocating treating Docker as heavyweight VMs.
评论 #7951102 未加载
评论 #7951068 未加载
评论 #7951834 未加载
评论 #7951139 未加载
评论 #7952070 未加载
ksikkaalmost 11 years ago
Volumes are convenient! But what do you do if you have a multi-host setup? Multiple volumes, shared volumes, distributed file systems, NFS? What do you use when?
评论 #7951404 未加载
x1798DEalmost 11 years ago
Reading some of the other comments in this thread, I think I&#x27;m getting a better idea of why this guy is suggesting that SSH in Docker could complicate things, especially when you are scaling to a large number of servers, but what I still don&#x27;t quite understand his argument about security updates. Is that in any way SSH specific, beyond the fact that SSH is powerful and it&#x27;s critical to be up-to-date on powerful things?<p>If it&#x27;s a problem to update SSH, then it should also be a problem to update whatever else you have in your Docker container. I guess there&#x27;s some argument to be made that if you&#x27;re running a single-purpose Docker container, the updates to whatever service it&#x27;s running won&#x27;t sync up with the updates to SSH, so you may drastically increase the number of times you&#x27;ll have to package the image, but that&#x27;s just a general argument in favor of single-purpose containers, not anything specific to SSH like the key management issue.
liftyalmost 11 years ago
Its funny that he uses Docker as a build and installation tool for nsenter. If you look at the installation example from the nsenter github page it shows how you can mount your host&#x27;s &#x2F;usr&#x2F;local&#x2F;bin inside the container where nsenter will be built. Pretty nifty&#x2F;hacky way for building software and keeping your system clean.
vbitalmost 11 years ago
Wow. Given all the hype around docker, I&#x27;m really surprised nsenter type functionality isn&#x27;t part of the core. Glad I&#x27;m using FreeBSD where running a shell in your jail is just &#x27;jexec my_jail bash&#x27;. Compare that to the rigamarole described in the article. Maybe the docker guys will benefit from just reviewing the tooling for existing systems. I also recommend a look at ezjail-admin.
评论 #7952424 未加载
jaybuffalmost 11 years ago
nsenter might be a short term solution, but IMHO, getting a resolution to this issue <a href="https://github.com/dotcloud/docker/issues/1228" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dotcloud&#x2F;docker&#x2F;issues&#x2F;1228</a> so you can just do &quot;docker exec &lt;cid&gt; &#x2F;bin&#x2F;bash&quot; is much simpler than the nsenter call he recommends. Plus, he leaves out chroot, so I have a different view of the filesystem than PID 1 inside the container does.
atoponcealmost 11 years ago
As a cloud hosting provider, I don&#x27;t want to give customers access to the hardware node. Then what?
drydotalmost 11 years ago
i don&#x27;t see that wrong to setup the ssh service, if i accept ssh daemon is safe which i do.
评论 #7951065 未加载
评论 #7950969 未加载
zobzualmost 11 years ago
its all about useability basically use nsenter.<p>other points in the blog are true but its not what people want. people want nsenter, but they dont know, so they use ssh.
yebyenalmost 11 years ago
Typo: where a special key with force a specific command