Docker-Compose: “Can't find a suitable configuration file in this directory or any parent”

August 25, 2019 214 views
Docker Linux Basics Ubuntu 18.04

I am trying to run application by using docker-compose build command after pulling the image from docker using docker pull ajitgoel/socialmediascrubber command. I am however getting a

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

error. Running the ls | grep *compose.yml also does not return any results. What am I missing?

root@docker-socialmediascrubber:/# docker pull ajitgoel/socialmediascrubber
Using default tag: latest
latest: Pulling from ajitgoel/socialmediascrubber
Digest: sha256:f34ec5b1e8151c6ed12a02eba06c63f847a858e13f6e68eeae3ebf40bf7c7e04
Status: Image is up to date for ajitgoel/socialmediascrubber:latest
root@docker-socialmediascrubber:/# ls -ltr
total 88
drwxr-xr-x  2 root root  4096 Apr 24  2018 home
drwxr-xr-x  2 root root  4096 Jun 17 22:51 srv
drwxr-xr-x  2 root root  4096 Jun 17 22:51 mnt
drwxr-xr-x  2 root root  4096 Jun 17 22:51 media
drwxr-xr-x 10 root root  4096 Jun 17 22:51 usr
drwxr-xr-x  2 root root  4096 Jun 17 22:51 lib64
drwx------  2 root root 16384 Jun 17 22:55 lost+found
drwxr-xr-x 13 root root  4096 Jun 20 13:54 var
drwxr-xr-x 22 root root  4096 Jun 25 14:55 lib
drwxr-xr-x  2 root root 12288 Jun 25 14:57 sbin
drwxr-xr-x  2 root root  4096 Jul 12 03:13 snap
drwxr-xr-x  3 root root  4096 Jul 12 03:13 opt
drwxr-xr-x  2 root root  4096 Jul 13 06:33 bin
lrwxrwxrwx  1 root root    30 Aug 15 06:39 vmlinuz.old -> boot/vmlinuz-4.15.0-55-generic
lrwxrwxrwx  1 root root    30 Aug 15 06:39 vmlinuz -> boot/vmlinuz-4.15.0-58-generic
lrwxrwxrwx  1 root root    33 Aug 15 06:39 initrd.img.old -> boot/initrd.img-4.15.0-55-generic
lrwxrwxrwx  1 root root    33 Aug 15 06:39 initrd.img -> boot/initrd.img-4.15.0-58-generic
drwxr-xr-x  4 root root  4096 Aug 16 06:16 boot
drwx------  6 root root  4096 Aug 25 15:58 root
dr-xr-xr-x 92 root root     0 Aug 25 15:59 proc
drwxr-xr-x 17 root root  3740 Aug 25 15:59 dev
drwxr-xr-x 27 root root   960 Aug 25 16:23 run
drwxr-xr-x 94 root root  4096 Aug 25 16:24 etc
dr-xr-xr-x 13 root root     0 Aug 25 16:32 sys
drwxrwxrwt  9 root root  4096 Aug 25 17:24 tmp

Docker-compose.yml file:

version: '3.4'

volumes:
  pgdata:

networks:
  frontend:
  backend:

services:
  db:
    image: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: <SomeStrongPassword>
      POSTGRES_DB: scrubber
      POSTGRES_USER: postgres  
    volumes:
      - pgdata:/var/lib/postgresql/data      
    networks:
      backend:

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
    depends_on:
      - db
    networks:
      backend:

  scrubber:
    image: ${DOCKER_REGISTRY-}scrubber
    environment:
      - ASPNETCORE_ENVIRONMENT=PRODUCTION  
    build:
      context: . 
      dockerfile: Dockerfile
    networks:
      frontend:
      backend:
    depends_on:
      - db
    ports:
      - 80:80
      - 443:443
1 Answer

Hello,

When running only docker-compose build you should have your docker-compose.yml in the same directory. At the moment you are running docker-compose build but there is no docker-compose.yml in your current directory so that’s why you are getting the error.

You either need to put the docker-compose.yml file in your current directory, or you need to specify the path to the file with the -f argument.

Also as a side note I would recommend having a look at the official Docker compose documentation here: https://docs.docker.com/compose/reference/overview/

Hope that this helps!
Regards,
Bobby

Have another answer? Share your knowledge.