Posts

Showing posts from September, 2017

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 to 8.8.8.8 that is the google dns. Because myserver is in fact an internal server it wouldn't resolve of course and se