简体   繁体   中英

Docker building fails: returned a non-zero code: 1

Dockerfile1

FROM ubuntu:latest
MAINTAINER ME
RUN apt-get update
RUN apt-get update && apt-get install -y net-tools \
&& apt-get install inetutils-traceroute \
&& apt-get install iputils-ping \
&& apt-get install xinetd telnetd

Dockerfile2

FROM ubuntu:latest
MAINTAINER ME
RUN apt-get update
RUN apt-get update && apt-get install -y net-tools
RUN apt-get update && apt-get install inetutils-traceroute
RUN apt-get update apt-get install iputils-ping
RUN apt-get install xinetd telnetd

Dockerfile3

FROM ubuntu:latest
MAINTAINER ME
RUN apt-get update
RUN apt-get install inetutils-traceroute
RUN apt-get install -y net-tools
RUN apt-get update apt-get install iputils-ping
RUN apt-get install xinetd telnetd

I tried all the above flavors of my dockerfile but every time I get the same error :

The command '/bin/sh -c apt-get update && apt-get install -y net-tools && apt-get install inetutils-traceroute && apt-get install iputils-ping && apt-get install xinetd telnetd' returned a non-zero code: 1

Someone posted an answer and deleted it before I could accept it. But here it is -

FROM ubuntu:latest
MAINTAINER ME

RUN apt-get update && apt-get install -y \
net-tools inetutils-traceroute \
iputils-ping xinetd telnetd

This works!!

try to use key -y for apt-get or apt managers, on docker side. For example:

RUN apt-get update
RUN apt -y install net-tools

Without -y, apt-get asks a clarifying question - "are you sure you want to install this?". Without answer docker droped installation with code 1. The issue in here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM