Category Archives: docker

How to get latest nginx version for docker proxy image

Reading Time: 1 minute


In this blog post I will provide practice how to get latest nginx version aligned with docker documentation.

You have web application, and you need proxy server. You decided to go with nginx using docker. Also, you need to modify original image, so you have your own Dockerfile that is based on official docker nginx image (first line in Dockerfile is FROM nginx:latest).

Everything is set up, and after some time, you realized that your

docker build

command does not gets latest nginx version despite the fact that you have in Dockerfile

FROM nginx:latest

This was my heuristic that failed. Then I tried solution that is not aligned with docker. In Dockerfile I put:

sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx

because nginx docker image is based on debian linux distribution.

Doing that, local docker image got bigger than it should be.

Investigating docker documentation for build, I found following for docker build option:

--pull false Always attempt to pull a newer version of the image

By default, option is set to false. So, in order that on every build you get latest nginx docker image, you should run following cmd:

docker build –pull

Your local docker image will have optimized size, based on original Dockerfile and your application would be more secure.


Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

How to change docker default route on Centos7

Reading Time: 2 minutes


In this post I will explain how to resolve following issue. You are connected via ssh to your centOS box. You successfully installed docker on that box and you started docker daemon using systemctl. Bang!, you are disconnected from your centOS box.

This happened to me. I had successfully installed docker on several boxes without a problem. Reality check, I just scratched the surface of my docker knowledge.

Reality check. This centos box was different than previous ones. I found out that it is in different network. Luckily, there was another box in same network that I can connect to. I ssh to that box and then from that box to the original centOS box. I  am in!

I was able to log in because they were in same network subnet. My laptop was in different range. What to do in order not to be bitten by this issue?

Before you start docker daemon with systemctl, run following cmd:

[ ~]$ route -n

route shows/manipulates routing table. Routing table describe where IP packets should go. Picture above shows ok situation. docker and linux box have different destination for packets.

In above example, docker took by default [source]. It reserves 65536 IP addresses for containers.

In my case, centOS box was in range 172.29., and docker took so from outside, docker took all the traffic, and my laptop was automatically disconnected.

How to change docker cidr range.

Before you start your docker daemon:

  1. run route -n
  2. check your box eth0 destination
  3. edit docker systemctl start file:
vi /usr/lib/systemd/system/docker.service

4. put docker containers in different ip range

Here is example how to set docker ip range from – [cidr calculator]:

ExecStart=/usr/bin/dockerd -bip

5. Now is save to start docker daemon:

# systemctl daemon-reload
# systemctl start docker
#systemctl status docker
Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Docker behind a proxy

Reading Time: 1 minute


In this post I will explain how to set up docker when you are behind corporate proxy.

All Internet tutorials about any technology take assumption that you are not behind a proxy. Working for my client that must use corporate proxy, I spent a lot of working hours discovering how to use docker behind  a proxy.

You first need to find out value for corporate proxy. In corporate environment, this could be rather tricky action, because that value is not always publicly known.

  1. Set docker systemd settings to use proxy.

Use official docker instructions [source]. With this setting, docker daemon nows how to get images from the Internet.

2. Dockerfile.

If you need to tailor your own image, you need to use Dockerfile. In order to enable Dockerfile commands to get stuff from the Internet, you need to set ENV HTTP_PROXY variable.

After FROM directive in Dockerfile, put following settings:

FROM image_name
ENV http_proxy <HTTP_PROXY>
ENV https_proxy <HTTPS_PROXY>

3. Some tools do not use environment variable http_proxy.

There are some tools that made a wrong design decision where they do not use environment variable http_proxy, but they require that command switch must be used in order to set proxy value.

I broke my teeth on following tools:

  • pip
  • npm

Here is simple heuristic. If command from Dockerfile gets timeout (usually it appears to hang when it can not get to Internet), consult documentation for this command to find out how to set proxy value.

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Testing time variable using docker

Reading Time: 1 minute


As clouds passing by over your head, so the time passes through your product under test. Time is important testing variable that is often overlooked as source of test ideas.  Reason for that is that testers do not have appropriate tools to help them test time variable. I will provide simple example how docker can help us.

In my previous posts SIMULATING TIME IN RUBY ON RAILS and TESTING WITH TIME VARIABLE IS FUN! I already discussed time variable.

When you manage to learn docker basics, you are able to run on your local development machine various version of linux instances and services (nginx, apache, mysql) in matter of seconds.

 But you can control various variables of linux instances, not just product versions. And yes, you can control time variable. Time variable has several attributes: format, value, zone. And docker provides easy and SAFE way to change values of those attributes. Changing those values means that you only need to reboot your docker container. And if something breaks, you can have again old values in matter of seconds (all configuration variables are written in file that you can easily put under git control).

Here is example how to set docker container time ZONE. Changing time zone is important because in today’s web application world, frontend side application (javascript in browser) and backend application (Django, Rails, Node,…) usually have different time zones.

Create docker-compose.yml:

  image: mysql:5.7

and from that folder run:

>docker-compose up -d

No need to know how to actually set timezone in linux (Am I using bash or sh?), docker takes care of this. Your mysql instance is running in UTC time zone!

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Use docker for Linux

Reading Time: 1 minute


In this technical post I will explain how I resolved one of my previous issues, running chrome browser in headless in docker.

It seems that if you want to run various docker machines without strange issues, you have to install it on some of supported Linux platforms. For now, Mac and Windows platform are using VirtualBox images that can cause you a lot of headache.

You can go in two directions, create generic docker machine from your Mac (or Windows) on Linux. Or install docker-compose on Linux and do everything from that Linux shell.

I recommend later approach, and here is why.

Create generic docker machine option

You need to prepare Linux user on host machine with following configuration:

  1. user has to be sudoer with no password option
  2. ssh with no password authentication
  3. ssh with public key
  4. port 2376 and 22 opened on firewall

How did I found out those requirements that are not documented? Use docker-machine –debug option.

Why I do not recommend that approach? Because you will be able to communicate with that docker machine only from machine that created it. There are number of explanations how to connect to same docker-machine from two different computers, but none of those approaches worked for me.

Create containers from Linux terminal

I recommend that approach because you will be able to ssh to docker host machine from different computers using ssh.

And remember about my problem  running chrome in headless mode in docker container in VirtualBox? On docker installed on Linux they are not present!

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Be careful with docker upgrade

Reading Time: 1 minute


These days, updating software that we use is very easy. Installation scripts are automated and tested. In this post I will describe the issue caused with docker upgrade and how I analysed issue in order to resolve it.

In one of my previous post, I described how to create docker image for headless selenium chrome testing. And that worked for some time.

Then I needed to upgrade docker from version 1.9.1 to 1.10.2 because of this Docker 1.9.1 hanging at build step “Setting up ca-certificates-java” issue.

After upgrade, Chrome refused to start in docker image.

After I logged in to headless chrome docker container using configuration described in previous post:

>docker-compose run web bash
>"Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted"

Lets try to downgrade docker. But how to do that? I remembered that every docker machine has docker version:

docker-machine ls
default - virtualbox Running tcp:// v1.10.2 
dev * virtualbox Running tcp:// v1.9.1

Which means that with docker upgrade, only default machine is automatically upgraded.

So I switched to dev machine:

eval "$(docker-machine env dev)"

And using docker-compose I was able to run again cucumber headless chrome test:

docker-compose run web /bundle/bin/cucumber features/feature_name

One last issue. docker tool was upgraded, so when you run:

docker ps -a
Error response from daemon: client is newer than server (client API version: 1.22, server API version: 1.21)

Here comes docker version manager to the rescue. Install it and run its help:

dvm help


Docker is complex technology, it consists of great number of moving parts. Be very carefull when you decide to upgrade docker, especially when around early versions like 1.10.

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Headless browser testing in docker container

Reading Time: 2 minutes


In this post you will find out how to run headless chrome browser tests on your development machine using prepared and configured docker machine.

Docker enables you to run on your development machine minimal linux machine. You are in control which software will be installed in that linux machine. All linux machine configuration is stored in two files. Docker uses cache, so only changes in machine configuration are rerun.

Install Docker

First, you need to install Docker for your operating system. Fire up docker terminal after you installed it.

Type: docker-machine ls


Screen Shot 2016-02-14 at 11.11.42 AM


docker machine is linux (special docker flavour), that has docker software that will run your docker containers. It runs in virtualbox that is automatically installed with docker.

You can ssh to it:


Screen Shot 2016-02-14 at 11.19.15 AM


Clone this github repository that contains docker files needed for creating and running docker image. Follow the README instructions. And that it is, you can run headless chrome tests on your development machine. While those tests are running, you can use your development machine for other tasks.


Here is official Dockerfile reference documentation. Dockerfile is source code for creating docker images. But I would like to save you time that I spent investigating the official documentation, so you will be ready to create your own docker images very quickly.

Important note: in order to be able to create your own docker images, previously you have successfully configured and installed linux, connected to linux machine, and you know your way around in linux shell.

You do not have to create Dockerfile from scratch. There is great Dockerfile repository, called Docker hub. In search box input what you need, e.g headless chrome, and there is high probability that somebody already have prepared what you are looking for.

If this is not the case, you can download Dockerfile and change it according to your needs. Check in Dockerfile reference what every docker command actually do.


This is second file from docker ecosystem. It is a source code for creating docker containers and their interconnections based on docker machines. For example, WordPress site needs (according to good architecture practice) php container and mysql container.

Line 4 in docker-compose.yml maps current directory (your ui automation project folder) to web docker container app folder. That is the magic which enables docker to run your cucumber tests in docker linux container that is ready with headless chrome, something that is not possible on osx.

Volumes are important docker feature, because without them, docker container does not remember any changes.

Additional magic is that bundle install is run on docker-compose build only when Gemfile is changed.

For example:

  1. docker-compose run web bash
  2. cd ~
  3. touch text.txt
  4. exit
  5. docker-compose run web bash
  6. ls -al ~

There is no text.txt file!

Here is composer reference documentation.

Here are instructions how to start testing using headless chrome:

  1. in docker-composer.yml, replace {project_name} with name of your ui automation project folder name.
  2. copy Dockerfile, and docker-composer.yml to your ui automation project folder.
  3. start docker terminal, cd to ui automation project folder.
  4. run docker-compose build –force-rm
  5. run your tests: docker-compose run web /bundle/bin/cucumber -f html -o chrome.html features/feature_name.feature

chrome.html file is created in your local folder, in root folder of ui automation repository!


Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather