I'm trying to use docker compose to run my services. But for some reason I'm not able to call e.g. this command 'ls -la /home'. It gives me an error:
Cannot start service test: failed to create shim task: OCI runtime create failed: runc >create failed: unable to start container process: exec: "ls /home": stat ls /home: no such >file or directory: unknown
whereas when I use just 'ls' then I see all the directories... what's wrong?
Below is my docker-compose file:
version: "3"
services:
mqtt_broker:
build:
dockerfile: Dockerfile
context: ./
network_mode: host
test:
depends_on: [ mqtt_broker ]
image: ubuntu:22.04
command:
- ls -la /home
network_mode: host
CodePudding user response:
Enclose your command with the array notation (just like in Dockerfiles), so that it is properly joined together as one, instead of different parts being interpreted separately.
command: [ "ls", "-la", "/home" ]
CodePudding user response:
There is no command "ls -la /home"
. There is command ls
that takes -la
argument and /home
argument.
command:
- ls
- "-la"
- /home
Or alternatively, docker-compose will do the splitting if you pass a string instead of an array (consult YAML specification):
command: "ls -la /home"
Or just:
command: ls -la /home
CodePudding user response:
It might be a missing $PATH problem -- does the following work?
command:
- /bin/ls -la /home