Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose run returns /bin/ls cannot execute binary file

Tags:

docker

I have just started learning Docker, and run into this issue which don't know how to go abound.

My Dockerfile looks like this:

FROM node:7.0.0
WORKDIR /app
COPY app /app
COPY hermes-entry /usr/local/bin
RUN chmod +x /usr/local/bin/hermes-entry
COPY entry.d /entry.d
RUN npm install
RUN npm install -g gulp
RUN npm install gulp
RUN gulp

My docker-compose.yml looks like this:

version: '2'
services:
  hermes:
    build: .
    container_name: hermes
    volumes:
      - ./app:/app
    ports:
      - "4000:4000"
   entrypoint: /bin/bash
   links:
     - postgres
   depends_on:
     - postgres
   tty: true
postgres:
  image: postgres
  container_name: postgres
  volumes:  
    - ~/.docker-volumes/hermes/postgresql/data:/var/lib/postgresql/data
  environment:
    POSTGRES_PASSWORD: password
  ports:
  - "2345:5432"

After starting the containers up with:

docker-compose up -d

I tried running a simple bash cmd:

docker-compose run hermes ls

And I got this error:

/bin/ls cannot execute binary file

Any idea on what I am doing wrong?

like image 727
anhvutnu Avatar asked Aug 27 '26 22:08

anhvutnu


1 Answers

The entrypoint to your container is bash. By default bash expects a shell script as its first argument, but /bin/ls is a binary, as the error says. If you want to run /bin/ls you need to use -c /bin/ls as your command. -c tells bash that the rest of the arguments are a command line rather than the path of a script, and the command line happens to be a request to run /bin/ls.

like image 80
Typhlosaurus Avatar answered Aug 29 '26 13:08

Typhlosaurus