docker file cheat sheet

Version 0.0.1

FROM ubuntu:16.04

RUN apt-get update; apt-get install -y nginx
RUN echo 'hi, i am here' > /var/www/html/index.html

ENV http_proxy=proxy.tianxiaohui.com
ADD latest.tar.gz /var/www/wordpress
COPY somefile /var/some_place/ #compare to ADD, no magic
VOLUME ["/opt/project", "/data"]
WORKDIR
USER user:group
ARG webapp_user=user
ONBUILD
LABEL location="Shanghai" type="ep" //add image metadata
EXPOSE 80

ENTRYPOINT ["/usr/local/bin/my.sh", "-g"] #docker run command will be as argument for this
CMD ["/usr/local/bin/my.sh", "-l"] #only the last one works,and maybe override by docker run
#docker run --entrypoint 可以覆盖ENTRYPOINT, docker run 后边的command可以覆盖 CMD,如果有entrypoint, cmd 做参数

关于 ip tunnel 端口转发

The AllowTcpForwarding option in the OpenSSH server configuration file must be enabled on the server to allow port forwarding. By default, forwarding is allowed.

local forwarding:
$ ssh -L 80:intra.example.com:80 gw.example.com
$ ssh -L 127.0.0.1:80:intra.example.com:80 gw.example.com

remote forwarding:
$ ssh -R 8080:localhost:80 public.example.com
$ ssh -R 52.194.1.73:8080:localhost:80 host147.aws.example.com
$ ssh -R 2222:d76767.nyc.example.com:22 -R 5432:postgres3.nyc.example.com:5432 aws4.mydomain.net

https://www.ssh.com/ssh/tunneling/example
https://www.ssh.com/ssh/tunneling/
https://stackoverflow.com/questions/3653788/how-can-i-connect-to-oracle-database-11g-server-through-ssh-tunnel-chain-double

https://www.cyberciti.biz/faq/linux-unix-ssh-proxycommand-passing-through-one-host-gateway-server/

about SOCKS 协议

SOCKS: Socket Secure. OSI 模型的第五层, 提供代理服务, tcp, 默认1080端口, 提供用户名密码认证. SOCK4, SOCK5 2个版本.

https://en.wikipedia.org/wiki/SOCKS

about httpclient timeout

http://www.baeldung.com/httpclient-timeout
https://stackoverflow.com/questions/31611861/why-setconnectionrequesttimeout-doesnt-stop-my-1-min-get-request
Oracle Java parameters
https://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html

getConnectionRequestTimeout()
Returns the timeout in milliseconds used when requesting a connection from the connection manager.

getConnectTimeout()
Determines the timeout in milliseconds until a connection is established.

getSocketTimeout()
Defines the socket timeout (SO_TIMEOUT) in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets).

sun.net.client.defaultConnectTimeout (default: -1)
sun.net.client.defaultReadTimeout (default: -1)

These properties specify the default connect and read timeout (resp.) for the protocol handler used by java.net.URLConnection.
sun.net.client.defaultConnectTimeout specifies the timeout (in milliseconds) to establish the connection to the host. For example for http connections it is the timeout when establishing the connection to the http server. For ftp connection it is the timeout when establishing the connection to ftp servers.

sun.net.client.defaultReadTimeout specifies the timeout (in milliseconds) when reading from input stream when a connection is established to a resource.