I am building a docker stack based on alpine. Given my:
php7-dockerfile
:
FROM php:7-fpm-alpine
RUN apk update && \\
apk upgrade && \\
apk add --update autoconf gcc
and docker-compose.yml
:
version: "2"
services:
php:
build:
context: .
dockerfile: php7-dockerfile
container_name: test_php
volumes_from:
- data
On running docker-compose build
I am getting:
Building data
Step 1 : FROM busybox
---> 47bcc53f74dc
Step 2 : ADD ./web /var/www/html
---> Using cache
---> fc7f0c26a44d
Successfully built fc7f0c26a44d
Building php
Step 1 : FROM php:7-fpm-alpine
---> 86c28f7ac7f5
Step 2 : RUN apk update && \ apk upgrade && \ apk add --update autoconf gcc
---> Running in dc5c837f869c
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
v3.4.1-13-gdf6ff3e [http://dl-cdn.alpinelinux.org/alpine/v3.4/main]
v3.4.0-75-g8d1dc52 [http://dl-cdn.alpinelinux.org/alpine/v3.4/community]
OK: 5966 distinct packages available
/bin/sh: : not found
ERROR: Service 'php' failed to build: The command '/bin/sh -c apk update && \ apk upgrade && \ apk add --update autoconf gcc' returned a non-zero code: 127
I am confused as to why it uses /bin/sh
and why it is not found, as in my existing running container I can run
$ docker exec -it test_php /bin/sh
/var/www/html #
What am I doing wrong?
In order to use a newline on a combined RUN command, don't use \\\\
but \\
.
RUN apk update && \
apk upgrade && \
apk add --update autoconf gcc
The error message is misleading in this case.
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.