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.
- HTTP performs slow so restrictednetworks would be more likely to allow it as they are less likely to connect to things like file sharing networks.
- HTTP is connection-less (or conventionally so (see long polling) which reduces memory consumption .
- HTTP can be tested in a web browser which is slightly easier than using telnet.
- HTTP supports compression and encryption headers.
- HTTP has a standard for submitting the domain name allowing for Virtual Hosts
- HTTP supports basic auth.
- 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 HTTPmethod names like GET but if you can get past that, it can be pretty lucrative.
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 wantto 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.
docker run -d -e ROOT_PASS=mypass -p 23:22 -p 81:81 tifayuki/reverse-ssh-tunnel
Set mypass to the ssh password you want to use tofor 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 thisfor the container you want a port exposed on. your.domain.name being your external domain orIP address.
docker exec -it YOUR_CONTAINER_IDssh -p 23 -R 81:localhost:81your.domain.name