RUN apt-get update & apt-get -y install gcc
我尝试构建一个“helloworld”c 程序来映像,但是使用 cmd解析时发生构建错误,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 .
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
提示很粗糙,有人知道这是怎么回事吗?谢谢