Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

exec: "/bin/sh": stat /bin/sh: no such file or directory #63

Closed
yangtao309 opened this issue Sep 4, 2014 · 3 comments
Closed

exec: "/bin/sh": stat /bin/sh: no such file or directory #63

yangtao309 opened this issue Sep 4, 2014 · 3 comments

Comments

@yangtao309
Copy link

my Dockerfile

 Karaf Base Package build

FROM 10.200.187.96:5000/ubuntu

MAINTAINER Shuyun "tao.yang@shuyun.com"

# install jdk

RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:webupd8team/java

RUN apt-get update
RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get install -y oracle-java7-installer

RUN apt-get clean
RUN echo "JAVA_HOME=/usr/lib/jvm/java-7-oracle" >> /etc/environment

ENV JAVA_HOME /usr/lib/jvm/java-7-oracle

# install supervisor
RUN apt-get install -y supervisor
RUN mkdir -p /var/log/supervisor

# install sshd

RUN apt-get install -y openssh-server

RUN mkdir /var/run/sshd

RUN echo 'root:123456' | chpasswd

RUN sed --in-place=.bak 's/without-password/yes/' /etc/ssh/sshd_config

# install maven

RUN apt-get install -y maven


# install karaf

WORKDIR /home/runner

RUN apt-get update
RUN apt-get -y install wget

RUN apt-get -y install unzip

RUN wget -q http://repo2.maven.org/maven2/org/apache/karaf/apache-karaf/2.3.4/apache-karaf-2.3.4.tar.gz
RUN tar xzvf apache-karaf-2.3.4.tar.gz; mv apache-karaf-2.3.4 apache-karaf; rm -f apache-karaf-2.3.4.tar.gz

#RUN chown -R runner apache-karaf

WORKDIR /home/runner/apache-karaf/etc

# lets remove the karaf.name by default so we can default it from env vars
RUN sed -i '/karaf.name=root/d' system.properties


# lets add a user - should ideally come from env vars?
ADD datasource.dev.cfg /home/runner/apache-karaf/etc/datasource.dev.cfg

RUN echo >> users.properties
RUN echo admin=admin,admin >> users.properties

# lets enable logging to standard out
RUN echo log4j.rootLogger=INFO, stdout, osgi:* >> org.ops4j.pax.logging.cfg

WORKDIR /home/runner/apache-karaf

# ensure we have a log file to tail
RUN mkdir -p data/log
RUN echo >> data/log/karaf.log

# add run script
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf

ADD run /usr/local/bin/run
RUN chmod +x /usr/local/bin/run


# wget nexus tar.gz for package
WORKDIR /tmp

RUN mkdir .m2

RUN wget -q http://xxx:xxx@domain:8091/nexus/content/groups/public/com/shuyun/ccms/ccms-parent-package/6.1.1-SNAPSHOT/ccms-parent-package-6.1

RUN tar xzvf ccms-parent-package-6.1.1-20140903.032400-1.tar.gz
RUN mv ccms-parent-package-6.1.1-SNAPSHOT ccms-parent-package
RUN rm -rf ccms-parent-package-6.1.1-20140903.032400-1.tar.gz
RUN cp -r ccms-parent-package/* /home/runner/apache-karaf/system/
RUN rm -rf ccms-parent-package

 expos many ports
EXPOSE 22 8181 8101 1099 2181 9300 61616

#CMD echo "starting Apache-Karaf container: "
CMD ["/usr/bin/supervisord"]

docker build has happend exception:

docker build -t shuyun/karaf-app:2.3.4 . 

err

Step 33 : ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
 ---> Using cache
 ---> 37a984c607ea
Step 34 : ADD run /usr/local/bin/run
 ---> Using cache
 ---> 452bb5e20ebf
Step 35 : RUN chmod +x /usr/local/bin/run
 ---> Running in 06d5035a88e1
2014/09/04 04:29:08 exec: "/bin/sh": stat /bin/sh: no such file or directory
@gangster
Copy link

gangster commented Sep 8, 2014

Seeing this too...

@dduportal
Copy link
Contributor

Hi !

It seems related to the AUFS backend of Docker itself : moby/moby#5135.
There is a known limit of 127 layers when using this storage backend. I think that your custom ubuntu image have a lot of layers.

Solution 1 : flatten your build

It can be a quick-win solution in your case.
Reading @yangtao309 Dockerfile, i see some things to change :

  • When using apt-get, put updates and install on the same line or you'll run in trouble (If apt-get update layer is cached with the version 1.0 of your package, the install will fail when 2.0 will be available as default). Anyway, you'll push the AUFS-127's limit
RUN apt-get update && apt-get install -y software-properties-common
  • I see what you're doing with different sections (one for java, one for maven, etc.), but using Docker cache should be considered when developing you image. One time the image has been built, the loop of changes won't be often : you should group you action (apt-get install all packages in one layer, run all shell script action on only one RUN)
RUN apt-get update && apt-get install -y software-properties-common maven opens-server ...
  • WORKDIR is a cool instruction when working with some wget/tar but it creates unused layers (it stole some precious layers when running around 127 and it weight a lot !). You should use it only one time at the end.
# install karaf
RUN cd /home/runner \
    && wget -q http://repo2.maven.org/maven2/org/apache/karaf/apache-karaf/2.3.4/apache-karaf-2.3.4.tar.gz \
    && tar xzvf apache-karaf-2.3.4.tar.gz \
    && mv apache-karaf-2.3.4 apache-karaf \
    && rm -f apache-karaf-2.3.4.tar.gz

A little bit of reading around that :

Solution 2 : switch Docker's storage backend

How to switch backend and use devicemapper instead of AUFS (or any other existing) ?
In boot2docker, you just have to :

  • Set a var in a Shell file :
    In /var/lib/boot2docker/profile (create it if not existing), add this line
DOCKER_STORAGE=devicemapper
  • Restart docker :
sudo /etc/init.d/docker restart

It will be persisted across reboots. Note you'll have to rebuild all (cache is not shareable between AUFS and others backends).

A little bit of (quick) reading around these storage backends : http://www.projectatomic.io/docs/filesystems/

Good luck !

@yangtao309
Copy link
Author

@dduportal
solution 1 is ok!
thank you very much.
this issue i will be closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants