Creating data-volumes with docker-compose

Hi

I want to create a data-volume container which will be mounted by another container. According to the docker docs I can use docker create to create a container and mount it’s volumes, however since I manage all my containers with docker-compose (1.5.2, old style configurations) I want to manage this container with docker-compose as well.

Is there a way to perform this with docker-compose?

Thanks in advance

Haim

Yes it is actually simple. See this example.

proxy:
image: nginx:latest
net: your-network
ports:

  • “80:80”
    volumes_from:
  • proxy-data

proxy-data:
image: nginx:latest
net: your-network

Forgive the wrong identation ^

Thanks John,

Just so I understand, If I don’t specify command (and there is no default Cmd in the image) then it will just create a container?

Sadly that didn’t work. I get an error:

Creating staging_assets_1
ERROR: No command specified

The relevant docker-compose section is:

assets:
  image: registry.company.com/webapp_assets/staging

Any ideas (without running a command that exits immediately - /bin/true)?

Thanks