# Where is docker.sock?

**URL:** <https://forums.balena.io/t/where-is-docker-sock/8122>\
**Category:** balenaOS\
**Tags:** docker\
**Created:** [May 9, 2019, 12:41pm UTC](https://forums.balena.io/t/where-is-docker-sock/8122 "2019-05-09T12:41:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthew.williams](https://avatars.discourse-cdn.com/v4/letter/m/eada6e/32.png) [@matthew.williams](https://forums.balena.io/u/matthew.williams)\
**Post date:** [May 9, 2019, 12:41pm UTC](https://forums.balena.io/t/where-is-docker-sock/8122/1 "2019-05-09T12:41:45Z")

</div>

Hi, I’m trying to run a Bamboo CI agent on my BalenaFin board. I’ve got the agent running as a container, but I need this container to be able to access the docker daemon so that it can start new containers.

I believe that I can get access to Docker from inside a container by accessing the `docker.sock` file, which normally lives in the `/var/run/` directory, but I can’t find it on my host container, or my child container.

So where does this live? Can we access it?

The closest I can find is this file:  
`/var/run/docker/libnetwork/1a192e6d36408164a0fcfa6802ee9a092872d699b749c635c26335e417090b59.sock`

---

<div class="post-metadata">

**Author:** ![shaunmulligan](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/shaunmulligan/32/34_2.png) [@shaunmulligan](https://forums.balena.io/u/shaunmulligan)\
**Post date:** [May 9, 2019, 12:46pm UTC](https://forums.balena.io/t/where-is-docker-sock/8122/3 "2019-05-09T12:46:51Z")

</div>

Hi, yup the socket can be exposed to the container, but it needs to be enabled using a special label on the service in the composefile. I made a basic example a while back using this, you can find it here: [https://github.com/shaunmulligan/simple-docker-env-resin](https://github.com/shaunmulligan/simple-docker-env-resin) and the specific label is here: [https://github.com/shaunmulligan/simple-docker-env-resin/blob/master/docker-compose.yml#L10](https://github.com/shaunmulligan/simple-docker-env-resin/blob/master/docker-compose.yml#L10) . The project needs to probably be updated a bit, but I think it should still work and should be a good starting point.

---

<div class="post-metadata">

**Author:** ![matthew.williams](https://avatars.discourse-cdn.com/v4/letter/m/eada6e/32.png) [@matthew.williams](https://forums.balena.io/u/matthew.williams)\
**Post date:** [May 10, 2019, 2:07am UTC](https://forums.balena.io/t/where-is-docker-sock/8122/6 "2019-05-10T02:07:47Z")

</div>

Awesome, thanks for your help Shaun!

I didn’t realise that `/var/run/balena.sock` is equivalent to `/var/run/docker.sock`.

I’ll add some additional setup I had to do in case anybody else stumbles upon this:

Once I managed to get the Docker CLI to see the Docker daemon, I started getting a permission denied error:

```auto
bamboo@4efb123f7ad1:~$ docker run hello-world
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/balena-engine.sock: Post http://%2Fvar%2Frun%2Fbalena-engine.sock/v1.39/containers/create: dial unix /var/run/balena-engine.sock: connect: permission denied.

```

I read online that I needed to add the user to the docker group, however I looked through the groups on the host and couldn’t find one called `docker`. I did find `balenena-engine` however, which had a group ID of 990. So in my Dockerfile I added a new group called `docker`, gave it a group ID of 990, and added my user to it:

```auto
RUN addgroup docker --gid 990 && adduser ${USERNAME} docker

```

After I did this everything worked!

---

<div class="post-metadata">

**Author:** ![CameronDiver](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@CameronDiver](https://forums.balena.io/u/CameronDiver)\
**Post date:** [May 10, 2019, 7:29am UTC](https://forums.balena.io/t/where-is-docker-sock/8122/7 "2019-05-10T07:29:57Z")

</div>

Great to hear, and thanks for the writeup!
