Use your own docker-compose.yml on the command line

Unique docker-compose.yml

If you want to rewrite your project's docker-compose.yml

docker-compose -f docker-compose.myenv.yml

By specifying a customized YAML file for the and -f options, the command will be executed based on the original Compose configuration file.

However, it is troublesome to specify it every time.

Shell config file

By adding the following to .bashrc etc., if there is a unique configuration file directly under the directory, docker-compose.myenv.yml will be applied when dc is executed.

.bashrc


function dc() {
    if [[ -f docker-compose.myenv.yml ]]; then
        echo 'Using docker-compose.myenv.yml'
        docker-compose -f docker-compose.myenv.yml $@
    else
        docker-compose $@
    fi;
}
alias dc=dc

Example

bash:.docker-compose.myenv.When you have yml


$ dc
Using docker-compose.myenv.yml
Define and run multi-container applications with Docker.
...

Recommended Posts

Use your own docker-compose.yml on the command line
Compile and run Java on the command line
Notes on updating Ubuntu from the command line (16.04 → 18.04, 18.04 → 20.04 both)
Use your own classes in the lib directory with Rails6
I want to use Java Applet easily on the command line without using an IDE
Use LocationAwareLogger for your own Logger
Use Docker on your M1 Mac
Instructions for installing and using the AWS command line (awscli) on CentOS
[Ruby On Rails] How to use simple_format to display the entered text with line breaks
Import the instance and use it on another screen
Try running the Embulk command with your Lambda function