Search code examples
ruby-on-railsdockerboot2docker

SocketError: No such file or directory - connect(2) for /var/run/docker.sock


I am trying to run a docker container inside a rails application, however I keep receiving the following error:-

container = Docker::Container.create({'Image' => 'mitc/judge'})

Excon::Errors::SocketError: No such file or directory - connect(2) for /var/run/docker.sock (Errno::ENOENT)`

The environment variables are set

bash-3.2$ env | grep DOCKER DOCKER_HOST=tcp://192.168.99.100:2376 DOCKER_TLS_VERIFY=1 DOCKER_CERT_PATH=/Users/ayushlodha/.docker/machine/machines/dev

The container is able to run hello world

bash-3.2$ docker run mitc/judge /bin/echo 'Hello world' Hello world bash-3.2$ docker run -it mitc/judge judge@4a19cdd8b328:/tmp/judge$

I am using Mac and Kitematic. What am I missing?


Solution

  • Since you are using Kitematic, the socket file hasn't been created yet. You nee to create it manually. You can use the command:

    eval "$(docker-machine env dev)"
    

    and then run your ruby application.

    Refer:

    https://github.com/swipely/docker-api

    https://github.com/kitematic/kitematic/issues/517