Docker Community Forums

Share and learn in the Docker community.

Difference between the docker and docker-compose

(Kaleeswaran Narayanan) #1

I want to know the exact difference between the docker and docker-compose.
And In docker-compose.yml file we have to set

  • redis ( This is an existing imageName, am i right…? ) .
    My question how the docker-compose linked / identified this image into an application , how they communicate each other …? How they transferred or shared their files …?

Have a lot of confusions / queries in docker-compose . Kindly clear me the understandings of those .

Kaleeswaran N

(Ross M Karchner) #2

Docker compose, at it’s simplest (describing a single container) simplifies the process of starting a container. Instead of passing in a bunch of arguments to docker run, you can describe them in the yaml file.

It can also build images that haven’t been built yet, so it can also automate some of what you’d use docker build for.

It gets more interesting (and useful) when you describe multiple containers in your yaml file-- you’re not just setting up a single container, but a while application, made up of several containers. You don’t NEED docker-compose to do this, but it’s certainly easier.

When you link containers (with or without docker compose), you create a DNS name in one container, that points to the other, and also allow traffic to the linked container (in your example, redis) on whatever ports you’ve chosen to expose

(Kaleeswaran Narayanan) #3

For the linking containers, if i supposed to expose 8443 port to redis and this container will be linked to other container . How this port visible to currently running container …? Is it any mapping available for that …??? . Still am not clear about “links in docker-compose.yml”

(Ross M Karchner) #4

Links in compose work exactly like links specified in the docker run command.

If the redis container EXPOSE’s 8443, then any container that is given --link=redis (or has ‘redis’ listed under ‘links’ in docker-compose.yml) will be able to communicate with the redis container, using the hostname ‘redis’, on port 8443.