Docker command fails during build, but succeeds while executed within running container

前端 未结 3 1133
小鲜肉
小鲜肉 2020-12-03 04:46

the command :

docker build -t nginx-ubuntu . 

whith the Dockerfile below :

FROM ubuntu:12.10
RUN apt-get update
RUN apt-get -y         


        
3条回答
  •  旧时难觅i
    2020-12-03 05:27

    As an alternative to @creak's answer, you can change the default working directory in a Dockerfile with the WORKDIR command:

    FROM ubuntu:12.10
    # Run update & install together so that the docker cache doesn't
    # contain an out-of-date APT cache (leading to 404's when installing
    # packages)
    RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install libpcre3 libssl-dev libpcre3-dev wget zip gcc
    ADD http://nginx.org/download/nginx-1.4.1.tar.gz nginx-1.4.1.tar.gz
    RUN tar -zxf nginx-1.4.1.tar.gz
    RUN wget --no-check-certificate https://github.com/max-l/nginx_accept_language_module/archive/master.zip
    RUN unzip master
    WORKDIR nginx-1.4.1
    RUN ./configure --add-module=../nginx_accept_language_module-master --with-http_ssl_module --with-pcre=/lib/x86_64-linux-gnu --with-openssl=/usr/lib/x86_64-linux-gnu
    

    This also affects the default directory when you use docker run (overridden by the -w switch).

提交回复
热议问题