Update docker compose command to run in IntelliJ
Asked Answered
C

2

6

I've create a new docker compose running configuration in intelliJ Community 2023.2.3 to run it just on pressing a button in Ubuntu 22.043 LTS.

configuration settings

But the comand the InteLLiJ runs is /usr/bin/docker compose -f /home/myuser/Projects/project-bin/docker-compose.yml -p airc-training --compatibility up backend postgres

I got the following message error:

unknown shorthand flag: 'f' in -f See 'docker --help'.

That's because the system cannot understand docker compose command. Only docker-compose

I tried to define an alias on .barshrc alias docker compose="docker-compose" without success. It works on command line but I still got the same error.

I look into the Jetbrains website but they don't have any specs about that.

I think that if IntelliJ runs /usr/bin/docker-compose -f /home/myuser/Projects/project-bin/docker-compose.yml -p airc-training --compatibility up backend postgres the problem is solved but there are no options for that.

enter image description here

In docker website says that docker-compose is the default command for linux.

I was able to create Shell scripts configurations that up and restart the containers. They work, but they don't show me the logs. And I need to insert the proper command to display them.

I want to avoid that and keep the usability just like a java application, where I run it and automatically can access to logs on run/debug window.

How can I make this work?

Czarism answered 12/10, 2023 at 9:7 Comment(2)
What IDE version do you use? Will it help to manually set "Docker compose executable" in "Settings | Build, Execution, Deployment | Docker | Tools"?Condillac
By default, It comes with /usr/bin/docker. If I run this way the code generated is the first one that I described above. If I change to /usr/bin/docker-compose I get this message: Cannot run program "/usr/bin/docker-compose": error=2, No such file or directory. Which makes sense. Exactly as the message says doesn't exist any file like this. I changed to /usr/local/bin/docker-compose but I says: "Docker Compose V1 is deprecated". I checked I'm using docker compose version 2.16.0. It worked partially, but it does not display if is running or not, which means that I have to see detailsCzarism
C
5

I have found a partial solution:

As y.bedrov said I had to go to

Settings | Build, Execution, Deployment | Docker | Tools

Docker tools

The docker compose executable, by default is: /usr/bin/docker. But if you using docker-compose instead of docker compose it won't work.

The result is like this: docker-compose set

However, it's not possible to see if the containers are up or put them down by configuration, as with every application.

But is it possible to do that in the Services window (ALT + 8), and see all logs or logs for each container separately as well.

stop, see, restart, logs

Czarism answered 13/10, 2023 at 9:46 Comment(0)
W
6

Setting the "Docker Compose executable" value to the docker executable itself worked in my particular case. IntelliJ inserted the compose sub-command as necessary.

Warrenwarrener answered 16/7 at 19:34 Comment(1)
This worked for me. Completely counter-intuitive fix, but this works. PyCharm had bugged my Docker install when I was switching the configuration file to point to a new docker-compose file. Would have never have thought of this myself.Setsukosett
C
5

I have found a partial solution:

As y.bedrov said I had to go to

Settings | Build, Execution, Deployment | Docker | Tools

Docker tools

The docker compose executable, by default is: /usr/bin/docker. But if you using docker-compose instead of docker compose it won't work.

The result is like this: docker-compose set

However, it's not possible to see if the containers are up or put them down by configuration, as with every application.

But is it possible to do that in the Services window (ALT + 8), and see all logs or logs for each container separately as well.

stop, see, restart, logs

Czarism answered 13/10, 2023 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.