anhvutnu
anhvutnu

Reputation: 105

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

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?

Upvotes: 6

Views: 16551

Answers (2)

Typhlosaurus
Typhlosaurus

Reputation: 1578

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.

Upvotes: 19

Chad Grant
Chad Grant

Reputation: 45382

You can't run Gulp and Node at the same time in one container. Containers should always have one process each.

If you just want node to serve files, remove your entrypoint from the hermes service.

You can add another service to run gulp, if you are having it run tests, you'd have to map the same volume and add a command: ["gulp"]

And you'd need to remove RUN gulp from your dockerfile (unless you are using it to build your node files)

then run docker-compose up

Upvotes: -2

Related Questions