compose: Error when trying to run docker-compose up. "oci runtime error: container_linux.go:247..."

When trying to launch a built container with docker-compose up I’m getting an error:

ERROR: for app  Cannot start service app: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"script/docker-entrypoint.sh\\\": stat script/docker-entrypoint.sh: no such file or directory\"\n"
ERROR: compose.cli.main.main: Encountered errors while bringing up the project.

I’ve tried reinstalling docker, docker-compose, virtualbox, rebuilding containers, recreating machines. Downgrading almost all of those things to previous versions. Literally retrying the whole docker instalation flow.

The problem occurs only in docker-compose up. Everything works fine when I use docker run .... The important thing is the whole setup works correctly on my OSX installation. Unfortunately my Xenial Ubuntu doesn’t want to cooperate.

I’ve checked the issues archive and couldn’t find an answer that would help me fix the problem.

Here are my whole setup configs: docker-compose.yml:

version: "2"
services:
  app:
    build: .
    volumes:
      - .:/app
    depends_on:
      - cache-redis
    links:
      - cache-redis
  nginx:
    image: nginx:1.11.1-alpine
    depends_on:
      - app
    links:
      - app
    ports:
      - "80:80"
    volumes:
      - ./config/nginx/app.conf:/etc/nginx/conf.d/default.conf
  cache-redis:
    image: redis:3.2.1-alpine
    volumes:
      - cache-redis:/var/lib/cache-redis/data

volumes:
  cache-redis:
    driver: local

Dockerfile

FROM jruby:9.1.2.0-jre-alpine

RUN apk --update --no-cache add build-base less git openssh

RUN mkdir -p /app

WORKDIR /app

COPY Gemfile Gemfile.lock ./

RUN gem install bundler && bundle install

COPY . ./

CMD ["script/docker-entrypoint.sh"]

script/docker-entrypoint.sh

#!/bin/sh
rm -f tmp/pids/server.pid
padrino s -h 0.0.0.0

docker-compose -v: docker-compose version 1.8.1, build 878cff1

docker version:

Client:
 Version:      1.12.2
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   bb80604
 Built:        Tue Oct 11 18:29:41 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.2
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   bb80604
 Built:        Tue Oct 11 17:00:50 2016
 OS/Arch:      linux/amd64

docker info:

Containers: 6
 Running: 1
 Paused: 0
 Stopped: 5
Images: 15
Server Version: 1.12.2
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 37
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.24-boot2docker
Operating System: Boot2Docker 1.12.2 (TCL 7.2); HEAD : 9d8e41b - Tue Oct 11 23:40:08 UTC 2016
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.9 MiB
Name: default
ID: G442:OWMQ:BPXD:7MK5:HM7J:R7PO:DNBP:ZSKI:HJH4:OCE4:UX36:M2PO
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 21
 Goroutines: 38
 System Time: 2016-10-18T09:18:30.024046419Z
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox
Insecure Registries:
 127.0.0.0/8

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 23
  • Comments: 92

Commits related to this issue

Most upvoted comments

you gotta make the docker-entrypoint.sh an executable before building the image:

chmod +x docker-entrypoint.sh

otherwise it cant be executed and you get the permission error.

I’ve managed to fix it. I had wrong permissions and needed to run docker-compose as sudo.

I am getting this error too, and sudo fixed it. However, there should be an alternative solution to this issue.

I’m getting a similar error and unfortunately sudo doesn’t fix this one.

ERROR: for grafana  Cannot start service grafana: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"/init-grafana-and-run.sh\\\": permission denied\"\n"

click on icon tray Docker > Settings… > Shared Drivers and select checkbox Shared: C and D Maybe it`s help you!

I had similar issue with my images and found this thread. In my case, It turned out that mounting the volumes is the source of confusion.

In your case, please make sure that app.conf is an existing file. ./config/nginx/app.conf:/etc/nginx/conf.d/default.conf

This will mount your local app.conf inside of the docker container. If it does not exist on your local machine, docker will create locally an “app.conf” directory, which is not what you would usually expect in this particular case.

I hope it will help you.

This issue shouldn’t be closed - it still happens, and sudo isn’t really a good solution when needing to point docker-compose at a remote machine for deployment.

This is with docker-compose 1.9.0.

Interestingly, if I ssh into the machine, docker-compose up -d completes without an error. So, for me, this only happens when running remotely.

Odd thing is, the mount in the error message is for a local path (in bold below) - referred to relatively in my docker-compose, so perhaps this is a relative/absolute path problem with docker-compose.

ERROR: for nginx Cannot start service nginx: invalid header field value “oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:359: container init caused \"rootfs_linux.go:53: mounting \\\\ "/data/www/aq/docker/nginx/default.conf \\\" to rootfs \\\"/var /lib/docker/aufs/mnt/8e3b80c25d85b70b78ea479a5f68373e236fdd3dafd62b241495907ace62da2f\\\" at \\\"/var/lib/docker/aufs/mnt /8e3b80c25d85b70b78ea479a5f68373e236fdd3dafd62b241495907ace62da2f/etc/nginx/conf.d /default.conf\\\" caused \\\"not a directory\\\"\""\n”

This is due to a line in docker-compose.yml trying to point nginx’s configuration back to the local filesystem:

    volumes:
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf

This should resolve to /home/root/docker on the remote, and /data/www/aq/docker locally. Instead, docker-compose seems to be trying to use the local path on the remote.

Happy to provide any other details/logs.

I’ve noticed having a CMD line in a dockerfile and a -command parameter in a docker-compose file will also trigger this error.

issue for me was that I recently changed windows password, Going into Docker settings -> shared drives, un-selecting my drive, apply, and then re-selecting (apply) fixed it.

I am so sorry to add to this issue after it has been opened:

But I found a way around this. Simply rebuild the image by running:

docker-compose build

And then start a container using the newly built image:

docker-compose up

That’s all.

I hope this helps

On Windows 10 I was encountering the same issue with Docker for Windows. This started happening and I couldn’t figure out why until I realized that I changed my OS credentials earlier in the day! I went into Docker Settings --> shared drives and clicked ‘Reset my credentials’. I was then asked for my new credentials and everything started up fine after that.

On windows 10 and just encountered this bug. Going into Docker settings -> shared drives and then unselecting my drive, apply, and then re-selecting (apply) seems to have fixed it. Thanks @artem-gavrylenko

If you’re using MacOS, you should make your host’s docker-entrypoint.sh executable too, not just on your Dockerfile. Got this from a tip, https://github.com/composer/docker/issues/7

Found it, I was not assigning options in the right order:

docker-compose run web -f docker-compose-prod.yml /bin/bash

fails while:

docker-compose run -f docker-compose-prod.yml web /bin/bash

works.

Those parameter order restrictions are quite of annoying. Never has so many issues with any Unix executable…

For what it is worth: sudo docker container prune fixed the issue for me.

Worked for me, thank you! 😄

@michalwarda @jakerobers I am experiencing this issue too. I think you should reopen the issue.

I am using a pretty vanilla install of Docker for Mac, and I can’t remember doing anything that would require this permission level on the docker-compose command.

@chielsen Seems like it may happen at least after Docker update. I solved this problem for me with restarting Docker daemon.

I had a similar error today. And after almost an hour of debugging and testing several of the provided solutions, the only thing that solved the problem was, a system Restart. True story.

click on icon tray Docker > Settings… > Shared Drivers and select checkbox Shared: C and D Maybe it`s help you!

Tu é pica mesmo

For what it is worth: sudo docker container prune fixed the issue for me.

you gotta make the docker-entrypoint.sh an executable before building the image:

chmod +x docker-entrypoint.sh

otherwise it cant be executed and you get the permission error.

It helped me. Thank you.

“volumes” binds directories… not files.

@imarchuang bind the “config” directory => elk/elasticsearch/config with /usr/share/elasticsearch/config

@chielsen bind “php-fpm” direcotry with /etc/php/7.1/fpm/conf.d directory

I am getting this error too, and sudo fixed it. However, there should be an alternative solution to this issue.

Instead of running as sudo simply run the command chmod a+x /path/to/your/script.sh to give permission to execute. This is much better than using sudo each time.

Iam also getting a similar but little different, Please help

docker-compose up Starting wapdocker_wordpress_1 … error

ERROR: for wapdocker_wordpress_1 Cannot start service wordpress: b’OCI runtime create failed: container_linux.go:345: starting container process caused “exec: \”/bin/sh\“: stat /bin/sh: no such file or directory”: unknown’

ERROR: for wordpress Cannot start service wordpress: b’OCI runtime create failed: container_linux.go:345: starting container process caused “exec: \”/bin/sh\“: stat /bin/sh: no such file or directory”: unknown’ ERROR: Encountered errors while bringing up the project.

Another issue can be when you bind a volume attached to the local directory and your entry point is located it the directory that was replaced in the container. Thus, docker tries to execute the entry point and doesn’t find it or gets a permissions denial.

click on icon tray Docker > Settings… > Shared Drivers and select checkbox Shared: C and D Maybe it`s help you!

A teammate just ran into this issue. @sajadghawami’s solution worked for us.

One note about the situation that may have caused this - she changed her Windows password the day before. While I don’t have the personal resources to validate this behavior, I think it would be easy to test that.

Just to add in to the other comments here by several people, this happened to me recently and I can confirm. I had recently changed the password, computer was restarted and docker-compose would not bring up the containers. Unchecking and rechecking the Shared Drive, followed by entering the updated password got everything up and running.

I was using alpine-based images and changed /bin/bash to /bin/sh and it worked ok 😃

In my case , yum install libseccomp libseccomp-devel.

I had this error a very stupid thing:

I was doing this

COPY ./package.json /frontend

Insetead of this:

COPY ./package.json /frontend/

I had this happen when trying to run a docker through docker toolbox in windows on WSL. For what it’s worth to anyone here, my problem was solved by making sure that i was accessing things through the windows rather than the linux file-system:

docker run -it --rm --name lispy -v “$PWD”:/Lis_Py python:3 python Lis_Py/lis.py || docker start -ia lispy

# on WSL with docker running in windows, $PWD will not work and must be set to the same as $PWD from docker quick-start, # viz. docker run -it --rm --name lispy -v /c/Users/firez/Documents/Development/lis.py:/Lis_Py python:3 python Lis_Py/lis.py || docker start -ia lispy

You either mount a specific file, or you mount a whole folder. You cannot mount a single file into a folder!

As taken from the link provided by @chielsen you can do this:

docker run --rm -it -v ~/.bash_history:/root/.bash_history ubuntu /bin/bash

which maps the users local .bash_history file into the container with the specified filename.

This issue happens on my native docker on Mac too… no idea how to resolve it!

ERROR: for elasticsearch  Cannot start service elasticsearch: oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:359: container init caused \"rootfs_linux.go:54: mounting \\\"/Users/mhuang/docker/elk/elasticsearch/config/elasticsearch.yml\\\" to rootfs \\\"/var/lib/docker/aufs/mnt/f41ff7a7a6fff5c6aa141ff8e9ca2d8c85740e4c7c707c6f720312703392b84a\\\" at \\\"/var/lib/docker/aufs/mnt/f41ff7a7a6fff5c6aa141ff8e9ca2d8c85740e4c7c707c6f720312703392b84a/usr/share/elasticsearch/config/elasticsearch.yml\\\" caused \\\"not a directory\\\"\""
: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

below are some info about my docker:

$ docker version
Client:
 Version:      1.13.1
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 08:47:51 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      1.13.1
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 08:47:51 2017
 OS/Arch:      linux/amd64
 Experimental: true
$ docker info
Containers: 15
 Running: 0
 Paused: 0
 Stopped: 15
Images: 38
Server Version: 1.13.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 380
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1
runc version: 9df8b306d01f59d3a8029be411de015b7304dd8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.8-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952 GiB
Name: moby
ID: 247X:LGNT:FJ4M:U6XE:T47E:WXLQ:VFXY:D3Z2:MBPI:KMAL:32LQ:DDHF
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 17
 Goroutines: 27
 System Time: 2017-02-22T19:00:56.756261436Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false