Posts

Useful docker commands

Image
Stop All Docker Containers docker stop $(docker ps -q) Remove All Docker Containers docker rm $(docker ps -a -q) Remove All Docker Images docker rmi $(docker images -q)

Copy files to/from host to docker container

Image
Sometimes you need to save a log file form a container that you are running. For example you have an apache tomcat container and you want to save the access log to your local host. This what you do: #start the container docker run -d -p 8080:8080 --name tomcat9 tomcat:9-alpine #copy the access log to the hosts current directory docker cp tomcat9:/usr/local/tomcat/logs/localhost_access_log.2017-09-07.txt . Where /usr/local/tomcat/logs/localhost_access_log.2017-09-07.txt is the location of the file to copy and  . is your local folder. Adding a file to the container is similalry simple: docker cp myhostscript.sh tomcat9:/usr/local/tomcat/bin/. This will add the file myhostscript.sh to the running container's /usr/local/tomcat/bin folder. Reference: Docker documentation on cp

nginx: [emerg] host not found in upstream

I encountered the above error message on container start up when I was using the nginx docker image. There are several answers to be found on the Internet in relation to this problem, but somehow none of them worked for my case. I run the nginx docker command from command line like this: docker run --name nginx -p 80:80 \ -v ${HOME}/nginx/nginx.conf:/etc/nginx/nginx.conf:ro \ -it --rm nginx:1.13 In my nginx.conf file I had my upstream defined like this:  upstream authenticator {            server myserver;     } Where myserver was a separate internal host. The suggested solution is to add a resolver directive to the config with the ip of the nameserver. resolver 1.1.1.1;  upstream authenticator {            server myserver;     } That didn't work either. After investigating the containers /etc/resolve.conf file I found that it points...

tar: Exiting with failure status due to previous errors

If you are here it is likely that you are trying to make sense of the message above. In my experience it highlights that in the directory sturcture that you try to tar together there are some files that tar -> ie.: your user doesn't have read access to.

Running C++ in a browser

Image
If you are a c/cpp developer and want to run your code on a web, in browser there is a solution for you. First make sure that you code is portable ie.: can be compiled on multiple platforms. Then you can use a compiler called Emscripten that is capable to output asm.js compatible javascript code or webassembly code. Sounds good? There is more if your code uses OpenGL ES it will cross compile that to WebGL. Setting up the actual enviroment is a breeze as there is a docker container for that on docker hub.

Enable haproxy stats page

I used the following config values with tthe HAProxy 1.7 docker image to enable the statistics page. listen stats bind :2016 stats enable stats hide-version stats realm Haproxy stats uri /ha-stats stats auth admin:password  This will bind to port 2016 on your host and will reqest the username and password specified.

Detecting available java heap space in a contaner

Did you know that java before update 8u131 would ignore your container memory limit and simply would calculate heap size from the host memory size? Carlos Sanchez has written an excellent post about the subject. Please follow the link to his site to read it. Running a jvm in a container without getting killed.