What is the difference between dockerfile and docker-compose?

Docker-compose is the arrangement of the mirror, then docker-compose is not able to do Dockerfile can do?

  • Docker add command src must be a file?
  • There is a problem with git clone in Dockerfile
  • What are the best practices when you write dockerfile? Hope to get everyone's advice.
  • How is the docker container just going out?
  • How to make Dockefile on Windows
  • DockOne Technology Sharing (37): Fun Docker Mirror and Mirror Build
  • Dockerfile RUN svn encounter character set to ask
  • Dockerfile created by the system user, other ordinary users can not enter the user's home directory
  • 5 Solutions collect form web for “What is the difference between dockerfile and docker-compose?”

    I understand the docker-compose is the arrangement of the container. For example, you have a php image, a mysql image, a nginx image. If there is no docker-compose, then every time you start, you need to knock on the container startup parameters, environment variables, container naming, specify the different container link parameters and so on a series of operations, quite cumbersome. And after using the docker-composer, you can write these commands one at a time on the docker-composer.yml file, and every time you start the entire environment (with 3 containers), you just knock on a docker-composer Up command ok.

    The role of dockerfile is from scratch to build the mirror.

    Two are not exactly the same thing

    Feeling docker-compose is an extension of the docker function,
    Dockerfile can let you configure to run a container, but docker-compose can let you run a command to run multiple containers

    First understand the use of docker process, it is divided into mirror building and container startup.

    Mirror Build: Create a mirror that contains the environment required for installation, program code, and so on. The creation process is to use dockerfile to complete.

    Container Startup: The container is finally run by pulling the built-in mirror and initiating the service through a series of run instructions such as port mapping, external data mount, environment variables, and so on. For a single container, this can be run by the docker run.

    And if it involves multiple containers (such as service choreography) can be achieved through the docker-compose, it can easily run as a number of containers as a service (of course, can only run one of them), and provides a scale (Service expansion) function.

    Simple Summary:

    1. Dockerfile: build mirror;

    2. Docker run: start container

    3. Docker-compose: start service;

    Dockerfile – prepared for the docker build command, used to create a separate image, docker-compose can also be used for real-time build
    Docker-compose.yml – a script prepared for docker-compose that can manage multiple containers at the same time, including relationships between them, with official image or builds, various network port definitions, storage space definitions, etc.

    As the name suggests:

    Dockerfile, is a file that builds a single docker images and describes a docker images that need to be executed by the instructions contained.

    Docker-compose, docker multi-stream composition instructions, that is, multiple docker images build instructions compiled into a file, docker-compose build will docker-compose instructions compiled into multiple images, docker-compose can also use dockerfile as Subservice build file.

    Heads up! This alert needs your attention, but it's not super important.