Reputation:
I'm new to docker-compose
and after reading the docs I still have some unclear things that comes to my mind.
So far when I used docker I kept the builds in the following directory tree:
builds:
Service A:
Dockerfile
ServiceA.jar
Service B:
Dockerfile
ServiceB.jar
So when I want to run all I use some shell script, until I read about docker-compose
.
I saw that there are 2 ways of creating and running a service (in manner of copying files)
build: path/to/my/build/directory
and linking it with
volumes:
so it can see live code and refresh the serviceimage:
(for example java:8
) and then use the volumes:
as aboveWhat I want to understand is what is the best practice using docker-compose
before I dive in to it, should I create specify image
for each service (and replace with the FROM
inside the Dockerfile
) or should I specify paths to build folders and volumes to keep live code changes, and how does volumes
work and their usages when using image
tag
Thanks!
Upvotes: 3
Views: 1438
Reputation: 4968
In Docker you can simply run services as containers and you can put the state of each service in a volume. This means for you:
docker build
or the docker-compose build section.In your example this means:
docker-compose up -d
docker-compose up --build --force-recreate -d
. This command will rebuild all images and replace containers. Why you do not place the binaries inside the volume:
Upvotes: 2