# Proper docker-compose for microservices

**URL:** <https://forums.balena.io/t/proper-docker-compose-for-microservices/3402>\
**Category:** Product support\
**Created:** [June 27, 2018, 9:20pm UTC](https://forums.balena.io/t/proper-docker-compose-for-microservices/3402 "2018-06-27T21:20:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![paranic](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/paranic/32/1031_2.png) [@paranic](https://forums.balena.io/u/paranic)\
**Post date:** [June 27, 2018, 9:20pm UTC](https://forums.balena.io/t/proper-docker-compose-for-microservices/3402/1 "2018-06-27T21:20:21Z")

</div>

can someone port my docker-compose to a proper one for use with resin?  
yaml is on the same folder as laravel project and contains an nginx.conf file  
i prefer to use only docker-compose and not Dockerfiles with no specific reason

here is my yaml:

```
version: '3.2'
services:
 web:
  image: nginx:mainline-alpine
  ports:
    - "8080:80"
  volumes:
    - type: bind
      source: .
      target: /project
    - type: bind
      source: ./nginx.conf
      target: /etc/nginx/conf.d/default.conf
  links:
    - php

 php:
  image: php:7-fpm-alpine
  volumes:
    - type: bind
      source: .
      target: /project
  links:
    - db

 db:
  image: mariadb:latest
  environment:
    MYSQL_ROOT_PASSWORD: rootpass
    MYSQL_DATABASE: dbname
    MYSQL_USER: dbuser
    MYSQL_PASSWORD: dbpass

```

it works on a debian base docker host  
Thanks in advance  
Nikos

---

<div class="post-metadata">

**Author:** ![thgreasi](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thgreasi/32/454_2.png) [@thgreasi](https://forums.balena.io/u/thgreasi)\
**Post date:** [June 28, 2018, 1:01pm UTC](https://forums.balena.io/t/proper-docker-compose-for-microservices/3402/4 "2018-06-28T13:01:59Z")

</div>

Hi,  
We currently only support the short syntax and named volumes. Can you try changing that part and let us know whether it works for your use case?

Let me share with you a link to our related documentation page and a link to the docker compose docs.

See: [https://docs.resin.io/reference/supervisor/docker-compose/#docker-compose-yml-fields](https://docs.resin.io/reference/supervisor/docker-compose/#docker-compose-yml-fields)  
See: [https://docs.docker.com/compose/compose-file/#short-syntax-3](https://docs.docker.com/compose/compose-file/#short-syntax-3)

---

<div class="post-metadata">

**Author:** ![paranic](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/paranic/32/1031_2.png) [@paranic](https://forums.balena.io/u/paranic)\
**Post date:** [June 29, 2018, 9:48am UTC](https://forums.balena.io/t/proper-docker-compose-for-microservices/3402/6 "2018-06-29T09:48:16Z")

</div>

ok i changed my volumes to short syntax  
php:  
image: php:7-fpm-alpine  
volumes:  
- ./:/project  
links:  
- db

and now when i push to resin i get this message  
[Error] Could not parse compose file  
[Error] Missing volume definition for ‘./’  
[Error] Not deploying release.

---

<div class="post-metadata">

**Author:** ![thgreasi](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thgreasi/32/454_2.png) [@thgreasi](https://forums.balena.io/u/thgreasi)\
**Post date:** [June 29, 2018, 1:43pm UTC](https://forums.balena.io/t/proper-docker-compose-for-microservices/3402/7 "2018-06-29T13:43:23Z")

</div>

Hi again,  
I just realized that I should have pointed to you to the v2 docker-compose.yml docs where the first part should be a volume and `./` isn’t allowed.  
See: [https://docs.docker.com/compose/compose-file/compose-file-v2/#short-syntax](https://docs.docker.com/compose/compose-file/compose-file-v2/#short-syntax)

Try using something like this:

```auto
version: '2'
services:
  service1:
    build: ./service1
    expose:
      - "8080"
    volumes:
      - data-volume:/usr/src/app/tmp
    links:
      - db

volumes:
  data-volume:
  db:

```

see: [https://docs.docker.com/compose/compose-file/compose-file-v2/#volume-configuration-reference](https://docs.docker.com/compose/compose-file/compose-file-v2/#volume-configuration-reference)

---

<div class="post-metadata">

**Author:** ![paranic](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/paranic/32/1031_2.png) [@paranic](https://forums.balena.io/u/paranic)\
**Post date:** [June 29, 2018, 4:53pm UTC](https://forums.balena.io/t/proper-docker-compose-for-microservices/3402/9 "2018-06-29T16:53:11Z")

</div>

i have banging my head reading the docs  
where do i specify the source of the data-volume ?  
what wil be mounted on the /usr/src/app/tmp on the cointainer?  
docker will generate a random folder and mount this folder?  
i want to mount my project in the cointaner

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [June 29, 2018, 8:14pm UTC](https://forums.balena.io/t/proper-docker-compose-for-microservices/3402/10 "2018-06-29T20:14:32Z")

</div>

Hi @paranic,

Keep in mind that whatever you build on resin will be deployed to the devices by means of the resin API, so what will actually get to the device will be the docker-compose (in a modified version for the supervisor on the device to understand) with the corresponding docker images.

This means that your local development folder will not exist there, so you can’t bind mount your development folder into the container.

So I understand you prefer not to have Dockerfiles with no specific reason, but here the reason is that the way the code gets deployed to your fleet is via images, and therefore you need to use a Dockerfile rather than mounts.

Hope this clarifies a bit!

---

<div class="post-metadata">

**Author:** ![paranic](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/paranic/32/1031_2.png) [@paranic](https://forums.balena.io/u/paranic)\
**Post date:** [July 2, 2018, 11:31am UTC](https://forums.balena.io/t/proper-docker-compose-for-microservices/3402/12 "2018-07-02T11:31:27Z")

</div>

Hi @pcarranzav

so to get it straight  
i have to build a custom container witch will include my project files?  
and my project will reside inside the container and then be pulled by my device?

---

<div class="post-metadata">

**Author:** ![hedss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/hedss/32/210_2.png) [@hedss](https://forums.balena.io/u/hedss)\
**Post date:** [July 2, 2018, 12:56pm UTC](https://forums.balena.io/t/proper-docker-compose-for-microservices/3402/13 "2018-07-02T12:56:34Z")

</div>

Hi @paranic,

That’s absolutely correct, you’ll need to make your project files available via a container (although there’s nothing stopping you copying them to a named volume on startup and then sharing them with other containers).

---

<div class="post-metadata">

**Author:** ![paranic](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/paranic/32/1031_2.png) [@paranic](https://forums.balena.io/u/paranic)\
**Post date:** [July 2, 2018, 3:56pm UTC](https://forums.balena.io/t/proper-docker-compose-for-microservices/3402/14 "2018-07-02T15:56:18Z")

</div>

ok thanks for the clearing this up.  
i think this was not obvious on the documentation and on the examples on github but i guess i am not so experienced in docker to figure this out by my self.
