What is the difference between dockerfile and docker-compose?
- Docker run is the front run of the program, how to run better?
- Docker to-d mode when the flashback start, docker bridge network problems
- Docker-compose after each up, before the changes made in the container does not retain?
- How the docker overwrites the parent mirror entrypoint
- How do I run SPEC CPU 2006 in Docker?
- If you enter the Docker image of the bash environment?
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.
Dockerfile: build mirror;
Docker run: start container
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.