starting a machine in Docker with ports

docker run -p 800:80 -p 2222:22 -p  4443:443  -it 68715929d32a  /bin/bash If ports do not work check : sysctl net.ipv4.ip_forward if  you get: net.ipv4.ip_forward = 0 then issue : sysctl -w net.ipv4.ip_forward=1 net.ipv4.ip_forward = 1if you get the error :   docker: Error response from daemon: driver failed programming external connectivity on endpoint amazing_williams (44e256a6039741b20e4124800702d9794d69fb6be9da71ba25059de4dd527121):…

Centos 7 Firewall open a port

Use this command to find your active zone(s): firewall-cmd –get-active-zones It will say either public, dmz, or something else. You should only apply to the zones required. In the case of dmz try: firewall-cmd –zone=dmz –add-port=2888/tcp –permanent Otherwise, substitute dmz for your zone, for example, if your zone is public: firewall-cmd –zone=public –add-port=2888/tcp –permanent Then…

Docker log files

Ubuntu – /var/log/upstart/docker.log Boot2Docker – /var/log/docker.log Debian, GNU/Linux – /var/log/daemon.log CentOS6 – /var/log/daemon.log | grep docker Fedora – journalctl -u docker.service OpenSuSE – journalctl -u docker.service on Centos 7 journalctl -u docker.service nJoy 😉

Docker Remote API on CentOS

After installing Docker on CentOS we need to Docker remote API port on CentOS. $ cat /etc/sysconfig/docker other_args="" Edit the file /etc/sysconfig/docker as below. other_args="-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock" After that, restart docker and try to access the host from another host. $ sudo /etc/init.d/docker restart … $ curl $hostname:4243/images/json … For a systemd based Distro…

Save SSL keys for AWS Cloudfront

Assuming you have AWS cli installed : aws iam upload-server-certificate –server-certificate-name www.site.tld-cf –certificate-body file://public.key –private-key file://private.key –certificate-chain file://bundle.pem –path /cloudfront/ nJoy 😉  

hex2bin in node.js

Basically it’s all over-engineered and does not work well. responses are out of alignment and though text-wise they are the same bit wise everything is all over the place : curl http://phpimpl.domain.com/testhex.php | xxd 00000000: de56 a735 4739 c01d f2dc e14b ba30 8af0 .Q.%G9…..;.0.. curl http://nodejs.domain.com/ | xxd 00000000: c39e 56c2 a725 4739 c380 c3ad…

strace apache or process to detect bottlenecks

Sometimes you have a multi threaded / multi processed application and you need to see where are things hanging. ps auxw | grep sbin/apache | awk '{print"-p " $2}' | xargs strace   nJoy 😉

AWS permissions on buckets for users and roles

Full access for specific IAM user/role Type: bucket { "Version":"2012-10-17", "Statement":[ { "Action":[ "s3:*" ], "Effect":"Allow", "Principal":{ "AWS":[ "arn:aws:iam::ACCOUNT_ID:user/USERNAME_A", "arn:aws:iam::ACCOUNT_ID:user/USERNAME_B", "arn:aws:iam::ACCOUNT_ID:user/USERNAME_C", "arn:aws:iam::ACCOUNT_ID:role/ROLE_A", "arn:aws:iam::ACCOUNT_ID:role/ROLE_B", "arn:aws:iam::ACCOUNT_ID:role/ROLE_C" ] }, "Resource":[ "arn:aws:s3:::BUCKET_NAME", "arn:aws:s3:::BUCKET_NAME/*" ] } ] }