简体   繁体   中英

docker-compose only working in some directories

I have a very weird problem: docker-compose isn't working in system-directories. If i try to execute it in eg. /opt, /srv or /tmp he can't find my docker-compose.yml although the file exists, but if i try the same in /root it works perfectly fine. Image of commands and output

Here are some version information:

root@myhost:~$ docker-compose version
docker-compose version 1.25.5, build unknown
docker-py version: 4.4.1
CPython version: 3.6.9
OpenSSL version: OpenSSL 1.1.1  11 Sep 2018
root@myhost:~$ which docker-compose
/snap/bin/docker-compose
root@myhost:~$ lsb_release -d
Description:    Ubuntu 18.04.5 LTS

My history:

cd /opt/
ls docker-compose.yml
docker-compose up
cp docker-compose.yml ~/docker-compose.yml
cd ~
ls docker-compose.yml
docker-compose up
cat docker-compose.yml

My docker-compose.yml:

version: '2'
services:
  hello_world:
    image: ubuntu
    command: [/bin/echo, 'Hello world']

I couldn't find anything on the inte.net so far and absolutely have no clue why this happens. Do you have any idea why this happens?

I think you use snap package docker-compose if You remove docker-compose from snap and install it using another method. For example:

sudo snap remove docker
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
#if need
sudo ln -s /usr/local/bin/docker-compose /snap/bin/docker-compose
sudo rm /usr/bin/docker-compose

After it you can launch your docker-compose.yml wherever you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM