Starting container process caused “exec: \\”tail -f /dev/null\\”: stat tail -f /dev/null: no such file or directory

from–https://stackoverflow.com/questions/51398251/starting-container-process-caused-exec-tail-f-dev-null-stat-tail-f

 

Asked 
Viewed 2k times

2

Because I am trying to keep a container running I specified the “tail -f /dev/null” as command in the docker compose file:

version: '2'
services:
  serviceName:
  .
  .
  .

  command:
    - tail -f /dev/null
  stdin_open: true
  tty: true
  .
  .
  .

After I run docker-compose up I get the following error:

ERROR: for serviceName Cannot start service serviceName: b’OCI runtime create failed: container_linux.go:348: starting container process caused “exec: \”tail -f /dev/null\”: stat tail -f /dev/null: no such file or directory”: unknown’ ERROR: Encountered errors while bringing up the project.

However if I start the container from the CLI with the same command it works perfectly.

What actually happens under the hood and how can I make this work ?

Linux version of the container is: 4.9.87-linuxkit-aufs.

The host machine uses Windows 10 OS and the Docker for Windows version is: 18.03.1-ce-win65 (17513), docker compose 1.21.1

2 Answers

3

Would suggest trying:

command:
  - tail
  - -f
  - /dev/null

From the error message docker compose will consider the first element of the command array as the command name (including the spaces etc.).

0

command: ["tail", "-f", "/dev/null"]

in docker-compose.yml This worked for me

上一篇
下一篇