Http vs plain old sockets

In the old days. Most services did not use HTTP. FTP. IRC, SMTP specify there own language for communication. Nowadays, many more things are brought via Http. Social media apps. RSS. Git over http. Email APis over http. This site for example.

I can think of some examples why this is the case.

  1. HTTP performs slow so restricted networks would be more likely to allow it as they are less likely to connect to things like file sharing networks.
  2. HTTP is connection-less (or conventionally so (see long polling) which reduces memory consumption .
  3. HTTP can be tested in a web browser which is slightly easier than using telnet.
  4. HTTP supports compression and encryption headers.
  5. HTTP has a standard for submitting the domain name allowing for Virtual Hosts
  6. HTTP supports basic auth.
  7. Probably other stuff.

Sockets does not provide this stuff out of the box and you would have to roll your own. Web sockets are the connectionful version of HTTP.

HTTP of course adds it’s own overhead with the HTTP method names like GET but if you can get past that, it can be pretty lucrative.

live exposure of a container port

Say you have this docker container, but you want to expose a port that is not already open. One good way is to save the image and restart. This however, will cause some downtime. You also may not want any process to stop because you have not added all the daemons to your startup script. This may lead to “sad times”.

One cool way to expose this port is to is by using a reverse SSH tunnel. Reverse tunnels require specific SSH daemon settings and you also may not want to be bothered ensuring that it’s set right. Instead, a docker container can be run specifically to run SSH for this purpose. The command to do this, image provided by docker user tifayuki, is as follows.

Set mypass to the ssh password you want to use to for the reverse tunnel.

This command will expose port 81 on your container. port 23 is chosen as the ssh server that will be used for reverse tunneling.

Then run this for the container you want a port exposed on. your.domain.name being your external domain or IP address.