compose: "Can't find a suitable configuration file" on Ubuntu 18.04.1

I am running a fresh Ubuntu 18.04:

$ cat /etc/issue
Ubuntu 18.04.1 LTS \n \l

I added the APT apt-repositries as described here. I have docker 18.09.0 and docker-compose 1.22.0:

root@srv:/docker# docker version
Client:
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:49:01 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:16:44 2018
  OS/Arch:          linux/amd64
  Experimental:     false
root@srv:/docker# docker-compose version
docker-compose version 1.22.0, build unknown
docker-py version: 3.5.0
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
root@srv:/docker#

I want to use docker-compose in a folder called /docker:

root@srv:/docker# ls -l
total 4
-rwxr-xr-x 1 administrator docker 458 Nov 22 13:44 docker-compose.yml

If I hit docker-compose up, I get the following error:

ERROR:
        Can't find a suitable configuration file in this directory or any
        parent. Are you in the right directory?

        Supported filenames: docker-compose.yml, docker-compose.yaml

Any idea? How can I debug that issue?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 15
  • Comments: 34

Most upvoted comments

I ran into the same problem with a fresh Ubuntu 18.04 install, where I selected Docker from install options.

I had the exactly same issue. After some digging I found out that the docker-compose was installed as a “snap” package. Applications from snap packages are running in a sandbox and they do not see the /tmp directory where I happened to have my docker-compose.yml file. Solution:

sudo snap remove docker
sudo apt install docker.io docker-compose

You need to run your command in the same folder as your doocker-compose.yml file

I ran into the same issue and found an explanation in the docker/docker-snap README:

All files that docker needs access to should live within your $HOME folder.

If the docker-compose.yml is outside of the $HOME folder, docker-snap won’t see it.

Solution: Move the docker-compose.yml (and accompanying files) inside your $HOME directory.

I ran into the same problem with a fresh Ubuntu 18.04 install, where I selected Docker from install options.

The permissions was not the problem. But when I followed the “Install Compose” steps on https://docs.docker.com/compose/install/#install-compose it worked right away.

The original issue was probably a permissions problem, but I’m glad you could solve it regardless.

~$ docker-compose ps

There is no docker-compose.yml in your home directory. Please cd into the directory with that file first.

My workaround:

I assume, docker-compose was installed automatically, when I installed the docker-ce package. Since I wasn’t able to stop containers, I disabled Appmour. It seems, that this removed docker-compose as well. Thus, I installed docker-compose manually. Now, docker-compose works for me.

Same issue on fresh install with Ubuntu Server 20.04.1 LTS. Also selected docker from the recommended packages during install. docker-compose version 1.25.5, build unknown Docker version 19.03.11, build dd360c7

ubuntu@main:/auto$ ll
total 48
drwxr-xr-x  6 ubuntu ubuntu 4096 Jul 29 16:54 ./
drwxr-xr-x 21 root   root   4096 Jul 29 16:24 ../
drwxrwxr-x  9 ubuntu ubuntu 4096 Jul 29 16:40 .git/
-rw-rw-r--  1 ubuntu ubuntu   59 Jul 29 16:24 .gitattributes
-rw-rw-r--  1 ubuntu ubuntu    8 Jul 29 16:46 .gitignore
-rw-rw-r--  1 ubuntu ubuntu   83 Jul 29 16:24 .gitmodules
-rw-rw-r--  1 ubuntu ubuntu  819 Jul 29 16:24 README.md
-rw-rw-r--  1 ubuntu ubuntu 6913 Jul 29 16:43 docker-compose.yaml
drwxrwxr-x  2 ubuntu ubuntu 4096 Jul 29 16:24 media/
drwxrwxr-x  2 ubuntu ubuntu 4096 Jul 29 16:40 secrets/
drwxrwxr-x 14 ubuntu ubuntu 4096 Jul 29 16:39 services/
ubuntu@main:/auto$ docker-compose pull
ERROR: 
        Can't find a suitable configuration file in this directory or any
        parent. Are you in the right directory?

        Supported filenames: docker-compose.yml, docker-compose.yaml
        
ubuntu@main:/auto$ 

you need save as file docker-compose.yml to docker-compose.yaml

(this is just a recap for people landing here from Google)

Symptoms

When you run docker-compose up or docker-compose build, you get this message:

ERROR:
        Can't find a suitable configuration file in this directory or any
        parent. Are you in the right directory?

        Supported filenames: docker-compose.yml, docker-compose.yaml

If you run docker-compose --version, you get something like this:

docker-compose version 1.25.5, build unknown

Cause

This issue happens with Ubuntu’s default docker installation (when you check the “docker” option during the Ubuntu installation). It happens in Ubuntu 20.04 and 21.04, and possibly in other versions.

Fix

  1. Uninstall the current docker version, and install the correct version
    sudo snap remove docker
    
  2. Install the correct docker-compose version by following the official instructions.
  3. Run docker-compose. If you get /snap/bin/docker-compose: No such file or directory, just start a new shell (or type bash).

docker-compose --version should now give you the correct version, with the correct build number, and run properly.

I ran into the same problem with a fresh Ubuntu 18.04 install, where I selected Docker from install options.

I had the exactly same issue. After some digging I found out that the docker-compose was installed as a “snap” package. Applications from snap packages are running in a sandbox and they do not see the /tmp directory where I happened to have my docker-compose.yml file. Solution:

sudo snap remove docker
sudo apt install docker.io docker-compose

I had the same issue as well (Ubuntu fresh install + selected docker during installation). However, executing the above commands didn’t quite fix it, I got this error:

-bash: /snap/bin/docker-compose: No such file or directory

I downloaded the binary (per instructions from the documentation) and had to remove the old snap script:

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo rm /usr/bin/docker-compose

After that docker-compose works fine, but it seems snap remove didn’t clean up very well.

sudo -i helped me

@prvak’s solution worked for me. Muchas gracias!

Since I am not the only one, I’ll try to create a MWE.

@xy2z I assume, you just overwrote the docker-compose Binary, which was installed by docker.

This worked on Mac (M1)

Thanks @paradoxministry !

I reproduced this problem on OSX Big Sur 11.4 with Docker for Mac 3.5.2.

Re-installing docker-compose with brew did NOT work for me. What did work was disabling Docker Compose v2 in my Docker for Mac preferences: image

Same problem on macOS.

In my case the docker-compose.yml file is in the immediate parent of the working directory.

After upgradint Docker Desktop to latest version

Version 3.4.0 (65384) Engine 20.10.7 Compose 2.0.0-beta.3 Credential Helper 0.6.4 Kubernetes v1.21.1 Snyk v1.563.0

The /user/local/bin/docker-compose was overriden by docker. To solve this I’ve re-installed brew reinstall docker-compose (to install brew install docker-compose)

yes. the same on on a fresh ubuntu 20.