Test Container test cases are failing due to “Could not find a valid Docker environment”

In my case this error caused by root permission. If you are using ubuntu, docker wants permission to create container and testcontainers can not ask you for this permission at runtime. So you need to make docker runnable without sudo.

Try this steps to create docker group and add connected user:

$ sudo groupadd docker
$ sudo gpasswd -a $USER docker
$ sudo service docker restart

Try this in step 3 if you are using Ubuntu 14.04-15.10:

$ sudo service docker.io restart

After all steps try some docker command in terminal without sudo like:

$ docker ps

If you are taking permission error, restart your computer then this must be fixed.

Leave a Comment