Docker: Dockerfile vs docker-compose.yml

I have a Dockerfile as the following:

FROM docker/whalesay:latest
RUN apt-get update && apt-get install -y fortunes
CMD while true; do /usr/games/fortune -a | cowsay; sleep 2; done

I have built the above Dockerfile as image: docker-whale

  • Deis not creating a build when pushing application
  • Passing a list of arguments to docker at build / run time
  • LXC integration and auto-scaling with Mesos
  • Docker-compose network link
  • nginx in docker how to disable http redirects to https
  • docker: command not found with Jenkins build and publish plugin on Mac
  • I want to write a docker-compose.yml for the above image. My understanding is that you can run multiple containers with docker-compose.

    So if i want to run 5 images of docker-whale, how does docker-compose.yml looks like?

  • Chef-Client fails to get the ruby gem during chef provisioning
  • ZMQ crashes “randomly” in aiohttp web service
  • Docker in Jenkins pipeline fails to run due to invalid environment variable: =
  • Docker swarm cluster and elasticsearch, using constraints to bind a service to a specific node
  • Kubernetes Docker Multi Node Setup issues
  • Docker containers as Linux services?
  • 3 Solutions collect form web for “Docker: Dockerfile vs docker-compose.yml”

    You could put this docker-compose.yaml next to your Dockerfile:

    version: '2'
        image: docker-whale
        build: .

    And then execute the following commands:

    # build docker image
    docker-compose build
    # bring up one docker container
    docker-compose up -d
    # scale up to three containers
    docker-compose scale docker-whale=3
    # overview about these containers
    docker-compose ps
    # view combined logs of all containers
    # use <ctrl-c> to stop viewing
    docker-compose logs --follow
    # take down all containers
    docker-compose down

    I assume you want to run 5 containers of docker-whale and not 5 images .

    In your case compose.yml will not have information about number of containers. You need to use scale command

    docker-compose scale <service-name>=5


      image: docker-whale

    Then inside same folder run:

    docker-compose up -d
    docker-compose scale docker-whale=5

    This assumes your application is scale-aware, but you still can write 5 entries in docker-compose.yml, this is screwdriver but sometimes useful:

      image: docker-whale
      image: docker-whale
      image: docker-whale
      image: docker-whale
      image: docker-whale
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.