当使用apt-get install gcc时Dockerfile生成错误
我试图build立一个“helloworld”c程序来形象,但是当parsingRUN apt-get update & apt-get -y install gcc
使用cmd sudo docker build .
RUN apt-get update & apt-get -y install gcc
,发生构build错误sudo docker build .
Dockerfile
非常简单,如下所示:
FROM ubuntu:16.04 COPY hd* ./ RUN apt-get update & apt-get -y install gcc RUN gcc ./hd.c -o hellodocker ENTRYPOINT ./hellodocker
工人目录如下:
$ ls -al total 32 drwxr-xr-x 2 root root 4096 Sep 6 02:42 . drwxr-xr-x 7 root root 4096 Sep 5 23:12 .. -rw-r--r-- 1 root root 386 Sep 6 02:38 Dockerfile -rw-r--r-- 1 root root 81 Sep 6 01:35 hd.c
hd.c是:
$ cat hd.c #include <stdio.h> int main(int argc, char **argv) { printf("hello docker\n"); }
在使用sudo docker build .
时遇到错误sudo docker build .
:
$ sudo docker build . Sending build context to Docker daemon 13.31 kB Step 1 : FROM ubuntu:16.04 ---> bd3d4369aebc Step 2 : COPY hd* ./ ---> Using cache ---> 348a98d816f0 Step 3 : RUN apt-get update & apt-get -y install gcc ---> Running in 205cd4de149c Reading package lists... Building dependency tree... Reading state information... E: Unable to locate package gcc The command '/bin/sh -c apt-get update & apt-get -y install gcc' returned a non-zero code: 100
提示非常粗糙,有人知道这是什么事吗? 谢谢
一个&符号将后台任务,这意味着install
在update
完成之前运行。
apt-get update & apt-get -y install gcc
你想&&
apt-get update && apt-get -y install gcc
你应该使用apt-get update && apt-get -y install gcc
with double'&'