EDIT: now Alpine may provide a bazel package...
ref: https://pkgs.alpinelinux.org/packages?name=bazel*&
I want to install bazel from testing repository in my Dockerfile.
FROM alpine:edge AS env
RUN apk add --no-cache git build-base bazel
CMD [ "/bin/sh" ]
observed:
$ docker build --target env -t test .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM alpine:edge AS env
---> 24cae4d038c0
Step 2/3 : RUN apk add --no-cache git build-base bazel
---> Running in 6ce08db21af0
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
bazel (missing):
required by: world[bazel]
The command '/bin/sh -c apk add --no-cache git build-base bazel' returned a non-zero code: 1
Simply use:
# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/alpine
FROM alpine:edge AS env
RUN apk add --no-cache git build-base
RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing bazel
CMD [ "/bin/sh" ]
Related
I was following this guide for building a simple docker image, but encountered error:
executor failed running [/bin/sh -c apk add --no-cache python g++ make]: exit code: 21
Following is the Dockerfile I'm using:
# syntax=docker/dockerfile:1
FROM node:12-alpine
RUN apk add --no-cache python g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
Please suggest me a solution.
replace python with python2
RUN apk add --no-cache python2 g++ make
Phyton is now missing from source and was replaced by python2
I have dummy Dockerfile:
FROM python:3.8-alpine3.13 AS python-base
RUN echo http://mirror.yandex.ru/mirrors/alpine/v3.13/main > /etc/apk/repositories; \
echo http://mirror.yandex.ru/mirrors/alpine/v3.13/community >> /etc/apk/repositories
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random
FROM python-base as builder-base
WORKDIR /app
RUN apk update && apk add --no-cache \
gcc musl-dev postgresql-dev openldap-dev gettext-dev \
libffi-dev openssl-dev python3-dev jpeg-dev zlib-dev musl-locales \
musl-locales-lang postgresql-libs libjpeg graphviz-dev ttf-freefont
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY pythonapline .
RUN python manage.py migrate
RUN python manage.py compilemessages
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
FROM builder-base as development
RUN pip install fastapi
RUN echo 'DEVELOPMENT'
FROM builder-base as test
RUN echo 'TEST'
When I want to build an image under target test I perform the command:
docker build -t myimage --target=test .
But I noticed that instructions under target development are also performed:
....
Step 16/18 : RUN echo 'DEVELOPMENT'
---> Running in 4cfa2ed80350
DEVELOPMENT
Removing intermediate container 4cfa2ed80350
---> 935d770dfe6d
Step 17/18 : FROM builder-base AS test
---> 442c02445aae
Step 18/18 : RUN echo 'TEST'
---> Running in 13432a53bec0
TEST
Removing intermediate container 13432a53bec0
---> 96e80f6d9603
Successfully built 96e80f6d9603
Is that expected? If no what's going on?
The --target option doesn't mean "start with this target" or "only build this target"; it means "stop at this target".
So if you specify --target test, Docker will run the test stage and every stage that precedes it.
So I can't seem to figure this out, but I'm getting error code 127 when running a Dockerfile. What causes this error?
My Dockerfile:
FROM composer as comp
FROM php:7.4-fpm-alpine
COPY --from=comp /usr/bin/composer /usr/bin/composer
COPY ./docker/install-deps.sh /tmp/install-deps.sh
RUN echo $(ls /tmp)
RUN /tmp/install-deps.sh
COPY . /var/www
WORKDIR /var/www
RUN composer install -o --no-dev
The results after building the Dockerfile:
Building php
Step 1/9 : FROM composer as comp
---> 433420023b60
Step 2/9 : FROM php:7.4-fpm-alpine
---> 78e945602ecc
Step 3/9 : COPY --from=comp /usr/bin/composer /usr/bin/composer
---> 46117e22b4de
Step 4/9 : COPY ./docker/install-deps.sh /tmp/install-deps.sh
---> 7e46a2ee759c
Step 5/9 : RUN echo $(ls /tmp)
---> Running in aa1f900032f9
install-deps.sh
Removing intermediate container aa1f900032f9
---> eb455e78b7f6
Step 6/9 : RUN /tmp/install-deps.sh
---> Running in 6402a15cccb2
/bin/sh: /tmp/install-deps.sh: not found
ERROR: Service 'php' failed to build: The command '/bin/sh -c /tmp/install-deps.sh' returned a non-zero code: 127
The install-deps.sh:
#!/bin/sh
set -e
apk add --update --no-cache \
postgresql-dev \
mysql-client \
yaml-dev \
git \
openssl
docker-php-ext-install pcntl pdo_mysql pdo_pgsql
# yaml
apk add --no-cache --virtual .build-deps g++ make autoconf
pecl channel-update pecl.php.net
pecl install yaml
docker-php-ext-enable yaml
apk del --purge .build-deps
Docker is executing the install-deps.sh script. The issue is with a command inside install-deps.sh that is not recognized when docker attempts to run the script.
As you can see the script returns an error code of 127 meaning that a command within the file does not exist.
For instance - try this:
touch test.sh
echo "not-a-command" >> test.sh
chmod 755 test.sh
/bin/sh -c "./test.sh"
Output:
/root/test.sh: line 1: not-a-command: command not found
Now check the exit code:
echo $?
127
I would suggest running the script inside an interactive environment to identify/install the command that is not found.
I'm trying out Spark on Kubernetes. Just downloaded Spark 2.4.3 on an EC2 instance in my VPC. I have setup my proxy in /etc/sysconfig/docker and able to import and run docker images from docker hub.
Command: bin/docker-image-tool.sh -t k8s-spark-2.4.3 build
Sending build context to Docker daemon 261.4MB
Step 1/15 : FROM openjdk:8-alpine
---> a3562aa0b991
Step 2/15 : ARG spark_jars=jars
---> Using cache
---> 2f9744e85911
Step 3/15 : ARG img_path=kubernetes/dockerfiles
---> Using cache
---> ba02760dc2df
Step 4/15 : ARG k8s_tests=kubernetes/tests
---> Using cache
---> a630900ca584
Step 5/15 : RUN set -ex && apk upgrade --no-cache && apk add --no-cache bash tini libc6-compat linux-pam nss && mkdir -p /opt/spark && mkdir -p /opt/spark/work-dir && touch /opt/spark/RELEASE && rm /bin/sh && ln -sv /bin/bash /bin/sh && echo "auth required pam_wheel.so use_uid" >> /etc/pam.d/su && chgrp root /etc/passwd && chmod ug+rw /etc/passwd
---> Running in 6b2fe7f7fcc6
+ apk upgrade --no-cache
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz: network error (check Internet connection and firewall)
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz: network error (check Internet connection and firewall)
+ apk add --no-cache bash tini libc6-compat linux-pam nss
OK: 103 MiB in 54 packages
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz: network error (check Internet connec tion and firewall)
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz: network error (check Internet connection and firewall)
bash (missing):
required by: world[bash]
libc6-compat (missing):
required by: world[libc6-compat]
linux-pam (missing):
required by: world[linux-pam]
tini (missing):
required by: world[tini]
ERROR: unsatisfiable constraints:
The command '/bin/sh -c set -ex && apk upgrade --no-cache && apk add --no-cache bash tini libc6-compat linux-pam nss && mkdir -p /opt/spark && mkdir -p /opt/spark/work-dir && touch /opt/spark/RELEASE && rm /bin/sh && ln -sv /bin/bash /bin/sh && echo "auth required pam_wheel.so use_uid" >> /etc/pam.d/su && chgrp root /etc/passwd && chmod ug+rw /etc/passwd' returned a non-zero code: 4
Sending build context to Docker daemon 261.4MB
Step 1/9 : ARG base_img
Step 2/9 : FROM $base_img
pull access denied for spark, repository does not exist or may require 'docker login'
Sending build context to Docker daemon 261.4MB
Step 1/9 : ARG base_img
Step 2/9 : FROM $base_img
pull access denied for spark, repository does not exist or may require 'docker login'
Any idea how to fix this?
I tried running this after 'docker login' as well. Result is same.
Seems like your EC2 instance has no conection with internet
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz:
network error (check Internet connection and firewall)
I had this exact same problem from within an Ubuntu 16.04 VM running on my laptop.
I was able to download the packages with curl and to visit the alpine repository directories using a web browser, so I know the issue was not the network connection.
Believe it or not, the solution was to restart the docker service running within the VM.
I found this as a suggested solution when searching for one of the apline package loading errors and it worked!
I'm trying to install dash in the (dockerized) alpine linux.
My Dockerfile follows:
FROM alpine:latest
RUN \
echo "#community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
apk add --no-cache --update dash
ENV SHELL dash
CMD dash
the output I get:
Step 1/4 : FROM alpine:latest
---> 053cde6e8953
Step 2/4 : RUN echo "#community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && apk add --no-cache --update dash
---> Running in 680f3d4d7dda
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
dash-0.5.9.1-r0:
masked in: #community
satisfies: world[dash]
ERROR: Service 'dash_alpine' failed to build: The command '/bin/sh -c echo "#community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && apk add --no-cache --update dash' returned a non-zero code: 1
however based on the alpine linux package search it seems to be available in the community repo: https://pkgs.alpinelinux.org/packages?name=dash&branch=edge&repo=&arch=&maintainer=
What should I change to make it working?
I think your echo line is wrong.
This file works well for me.
FROM alpine:edge
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& apk add -U --no-cache dash