Docker Community Forums

Share and learn in the Docker community.

Creating data-volumes with docker-compose


(Babysnakes) #1

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


(John Bryan Sazon) #2

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 ^


(Babysnakes) #3

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?


(Babysnakes) #4

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