How to open/run YML compose file? - docker

How can I open/run a YML compose file on my computer? I've installed Docker for Windows and Docker tools but couldn't figure out how.

If you are asking how to open YAML files, then you can use some common editors like NotePad++ in windows or vim in linux.
If your question is about running the compose yaml file, then run this command from the directory where compose file is residing:
docker-compose -f {compose file name} up
You can avoid -f if your filename is docker-compose.yml

To manage .yml files you have to install and use Docker Compose.
Installation instructions can be found here: https://docs.docker.com/compose/install/
After the installation, go to your docker-compose.yml directory and then execute docker-compose up to create and start services in your docker-compose.yml file.
If you need more information, take a look to Docker Compose docs: https://docs.docker.com/compose

Related

docker-compose only works if yml file in home directory

For some reason, on Ubuntu 20.04 docker-compose up only works if my docker compose yaml file is in the user's home directory.
I've uninstalled docker, installed it with snap, installed with apt and no difference.
Why is this? I've never seen this on any other server and for some reason this happens here.
How do I fix this so I can run docker-compose from a directory containing a docker-compose.yml file and have it read the pwd?
I have tried the -f option and it does not help.

Does it matter if the docker compose file is named docker-compose.yml or compose.yml?

Looking at examples for docker compose files I found some named "compose.y(a)ml" instead of "docker compose.yml" or "docker-compose.yml" that I've seen. Does it matter if it's "compose." or "docker composer"?
Awesome Compose repo
I've tried to search for an answer online and tried reading on the docker documentation here but didn't figure it out.
https://docs.docker.com/compose/reference/
Thank you
If the file is named exactly docker-compose.yml, running docker-compose with no other options will find it. Otherwise, you must pass a docker-compose -f option with the alternate name, for every docker-compose command.
Style-wise, I'd recommend putting a file named exactly docker-compose.yml (and possibly a matching docker-compose.override.yml with developer-oriented settings) in your repository's root directory. If you're building a custom image, also put the Dockerfile (again, with exactly that name and capitalization) in the repository root directory.

How to alias docker-compose to docker compose?

From my understanding, docker compose is the latest version. This is the one at least I installed from docker official documentation.
I am working on a project that use docker-compose in their makefile.
How could I forward all the calls (and their arguments) from docker-compose to docker compose ?
I created an alias:
alias docker-compose="docker compose"
It works fine in terminal. But not in the make file.
One solution I've come up with is to create a little script.
File: /bin/docker-compose
Content:
docker compose "$#"
Alternatively, in order to respect previous container naming convention (with underscore delimiter _ over -):
docker compose --compatibility "$#"
To make the script executable: sudo chmod +x /bin/docker-compose.
You can check it with docker-compose version.
Docker desktop comes with the option to alias docker compose v2 in Settings > General:
If you wish to avoid any additional scripts, I recommend you to :
create your alias (in your ~/.profile | ~/.bash|zshrc file)
alias docker-compose="docker compose --compatibility $#"
source your ~/.profile|.zsh|bashrc file in your makefile.

Docker Airflow location of airflow config file

I installed the official Airflow Docker Image , but I need to find the airflow.cfg file. Where did Docker put this file?
I am using Mac.
use docker-compose and get the entire setup, you need more than the airflow. You will need the UI,flower, etc. Get the docker compose image from:
https://github.com/puckel/docker-airflow
Clone the repo and if you look at the volumes
https://github.com/puckel/docker-airflow/tree/master/config
in the compose file they map to the config. simply put the files in the config and run the compose. This will save you so much time.

Docker-compose commands in yml not working

I am new to docker and am trying to get a few containers up and running using a docker-compose.yml file. But when i run the following command inside the cocker toolbox cli
docker-compose.yml up
I get the following errors:
As you can see, if I run the command
docker-compose -v
I get the version and build info which means it has been installed.
I have googled a lot but failed to find any solution. Kindly suggest.
Thanks in advance
You're trying to run the .yml file. Compose doesn't work like that.
Just run: docker-compose in the directory where docker-compose.yml resides. Docker-compose will automatically find the file.
You tried to run a yml file (which at best, bash interprets as a script). You need to run docker-compose, not docker-compose.yml. The latter is the input config file to the former.
docker-compose config

Resources