Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What's the difference between docker compose and docker-compose.yml?


Asked by Helen Melton on Dec 02, 2021 Docker



The difference for me is that docker-compose --file docker-compose.yml up does not work either. But the works. the question that i'd have to y'all is from which working directory are invoking Compose. because i encounter the same when i have one of the subfolders beside of a Compose project as a working directory.
And,
Remember, docker-compose.yml files are used for defining and running multi-container Docker applications, whereas Dockerfiles are simple text files that contain the commands to assemble an image that will be used to deploy containers. So the workflow looks like this: Create Dockerfiles to build images.
Just so, Say, for example, the docker-compose.yml file is in ~/dockerbuild and the Dockercompose file is in ~/nginxbuild, you could declare that with the line: Save and close the file. You could then deploy the new container with the command (run from within the directory housing the docker-compose.yml file):
Accordingly,
You can give the image name and container name under the service definition. e.g. for the service called 'web' in the below docker-compose example, you can give the image name and container name explicitly, so that docker does not have to use the defaults.
Similarly,
In “detached” mode (-d), Compose exits after starting the containers, but the containers continue to run in the background. The docker-compose run command is for running “one-off” or “adhoc” tasks. It requires the service name you want to run and only starts containers for services that the running service depends on.