Compose: "no such file or directory" issue

Created on 25 Aug 2016  路  7Comments  路  Source: docker/compose

Hey,
I'm running docker for mac (1.12.1-rc1).
And my Dockerfile is

FROM node

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E9C74FEEA2098A6E && \
    echo "deb http://packages.dotdeb.org/ wheezy-php55 all" > /etc/apt/sources.list.d/php.list && \
  apt-get update && \
  apt-get install -y php5-cli php5-curl php5-fpm php5-gd php5-mcrypt php5-mysql php5-pgsql php5-sqlite
ADD php-fpm.conf /etc/php5/fpm/php-fpm.conf

VOLUME ['/www/web']
WORKDIR /www/

# Global install gulp
RUN npm set progress=false && \
    npm install --global --progress=false gulp bower && \
    echo '{ "allow_root": true }' > /root/.bowerrc

COPY package.json /www/package.json
RUN npm install

EXPOSE 8000 3000 3001

COPY docker-start.sh /www/docker-start.sh

docker-compose.yml

version: '2'
services:
  web:
    image: web
    ports:
      - 8000:8000
      - 3000:3000
      - 3001:3001
    volumes:
      - .:/www/web/
    entrypoint: /www/docker-start.sh
    container_name: web
    tty: true

When I run docker-compose up -d, I get the error no such file or directory

WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use the bundle feature of the Docker experimental build.

More info:
https://docs.docker.com/compose/bundles

Starting web

ERROR: for web  Cannot start service web: oci runtime error: exec: "/www/docker-start.sh": stat /www/docker-start.sh: no such file or directory
ERROR: Encountered errors while bringing up the project.

Could someone help me with this issue?
Thanks

kinquestion

Most helpful comment

Just a note in case somebody winds up here for the same reasons I did:

  • Various source control products (git for windows, TFS) will line endings from LF to CRLF
  • You might then scp a script with the windows-style line endings to the machine running the docker daemon

    • You might then use docker-compose on windows to create a build container

    • When docker calls that script, it will still have windows-style line endings

    • For reasons I don't understand, you might then get this error:

      : No such file or directory

    • You might then (wrongly) assume that this is a docker issue, and end up here

All 7 comments

What happens if you do docker run web /www/docker-start.sh?

Hey,
This is the content of _docker-start.sh_:

#!/bin/sh

# Change present working directory
# alias myproject="cd web"
# myproject

# Show present working directory
pwd

# Run bower install
bower install

# Run gulp
gulp

When I do

docker run -it --name web --rm -p 8000:8000 -p 3000:3000 -p 3001:3001 -v $(pwd):/www/web -w /www/web cmcdev/web sh /www/docker-start.sh

I get bower and gulp run as expected:

/www/web
[13:15:15] Using gulpfile /www/web/gulpfile.js
[13:15:15] Starting 'sass'...
[13:15:15] Starting 'js'...
[13:15:15] Starting 'svgmin'...
[13:15:15] Starting 'svgstore'...
[13:15:15] Starting 'svg2png'...
[13:15:15] Finished 'svg2png' after 2.54 ms
[13:15:15] Starting 'server'...
[13:15:15] Finished 'server' after 7.38 ms
[13:15:15] Starting 'browser-sync'...
[13:15:15] Finished 'browser-sync' after 22 ms
[13:15:15] Starting 'watch'...
[13:15:15] Finished 'watch' after 21 ms
[BS] Proxying: http://0.0.0.0:8000
[BS] Access URLs:
 -----------------------------------
       Local: http://localhost:3000
    External: http://172.17.0.2:3000
 -----------------------------------
          UI: http://localhost:3001
 UI External: http://172.17.0.2:3001
 -----------------------------------
PHP 7.0.10-2+deb.sury.org~xenial+1 Development Server started at Thu Sep  1 13:15:17 2016
Listening on http://0.0.0.0:8000
Document root is /www/web
Press Ctrl-C to quit.
[Thu Sep  1 13:15:17 2016] 127.0.0.1:44450 [200]: /
[13:15:17] Finished 'svgmin' after 1.6 s
[BS] 2 files changed (script.js.map, script.js)
[13:15:17] Finished 'js' after 1.64 s
[BS] 4 files changed (main.css.map, main.css, new.css.map, new.css)
[13:15:18] Finished 'sass' after 2.54 s
[13:15:18] Finished 'svgstore' after 2.59 s
[13:15:18] Starting 'svginject'...
[13:15:18] gulp-inject 1 files into inline-svg.php.
[13:15:19] Finished 'svginject' after 594 ms
[13:15:19] Starting 'default'...
[13:15:19] Finished 'default' after 3.39 渭s
[BS] Reloading Browsers...
[BS] Reloading Browsers...
[13:15:19] gulp-imagemin: Minified 7 images (saved 2.4 kB - 19.5%)

Does it work if you replace your entrypoint with sh /www/docker-start.sh?

Oh, yes, it works.
Thank you so much!

Actually if you're already in the correct directory you can run ./docker-start.sh. The shell won't let you run a script directly by name because it has the potential to introduce malicious or unexpected behaviour if there is for example a script in the current directory with the same name as an operating system command or script. By requiring the ./ at the beginning you're telling the shell that you do want to run this specific version of the script.

Just a note in case somebody winds up here for the same reasons I did:

  • Various source control products (git for windows, TFS) will line endings from LF to CRLF
  • You might then scp a script with the windows-style line endings to the machine running the docker daemon

    • You might then use docker-compose on windows to create a build container

    • When docker calls that script, it will still have windows-style line endings

    • For reasons I don't understand, you might then get this error:

      : No such file or directory

    • You might then (wrongly) assume that this is a docker issue, and end up here

You need glibc to be installed, e.g.

    # Based on https://github.com/sgerrand/alpine-pkg-glibc/
    apk add ca-certificates wget
    wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub
    GLIBC_VERSION='2.27-r0' && \
    wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk && apk add glibc-${GLIBC_VERSION}.apk && \
    wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk && apk add glibc-bin-${GLIBC_VERSION}.apk
Was this page helpful?
0 / 5 - 0 ratings

Related issues

guycalledseven picture guycalledseven  路  3Comments

DhairyashilBhosale picture DhairyashilBhosale  路  3Comments

bergtwvd picture bergtwvd  路  3Comments

squeaky-pl picture squeaky-pl  路  3Comments

dazorni picture dazorni  路  3Comments