mitchellh / boot2docker-vagrant-box

Packer scripts to build a Vagrant-compatible boot2docker box.
424 stars 183 forks source link

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

Closed yangtao309 closed 10 years ago

yangtao309 commented 10 years ago

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 commented 10 years ago

Seeing this too...

dduportal commented 10 years ago

Hi !

It seems related to the AUFS backend of Docker itself : https://github.com/docker/docker/issues/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 :

RUN apt-get update && apt-get install -y software-properties-common
RUN apt-get update && apt-get install -y software-properties-common maven opens-server ...
# 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 :

DOCKER_STORAGE=devicemapper
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 commented 10 years ago

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