How to install docker-compose on Alpine Linux 3.13 - linux

I'm trying to install docker-compose on Linux alpine 3.13 following the documentation at https://docs.docker.com/compose/install/
But when I try to install rust it throws the following error:
ERROR: unable to select packages:
so:libLLVM-11.so (no such package):
required by: rust-1.51.0-r0[so:libLLVM-11.so]
Anyone have any idea of how to fix this?

Since alpine 3.10, if you are in the container:
apk add --update docker-compose
Otherwise, on the dockerfile:
RUN apk add --update docker-compose
Note that this does not install docker, you should have it installed already

This worked for me on Alpine 3.13, you can also search for the packages on the official site.
apk add llvm11-libs --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main

Related

How to install google-cloud-bigquery on python-alpine based docker?

I'm trying to build a docker with python 3 and google-cloud-bigquery with the following docker file:
FROM python:3.10-alpine
RUN pip3 install google-cloud-bigquery
WORKDIR /home
COPY *.py /home/
ENTRYPOINT ["python3", "-u", "myscript.py"]
But getting errors on the pip3 install google-cloud-bigquery (too long for here)..
What's missing for installing this on python-alpine?
Looks like an incompatibility issue with the latest version of google-cloud-bigquery (>3) and numpy:
ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
Try specifying a previous version, this works for me:
RUN pip3 install google-cloud-bigquery==2.34.4
Actually it seems like not a problem with numpy, which builds smoothly with all the dependency libs install, but rather with pyarrow, which does not support alpine+pip build. I've found a workaround by using alpine pre-built version of pyarrow. It is much easier than building pyarrow from source. This build works for me just fine:
FROM python:3.10.6-alpine3.16
RUN apk add --no-cache build-base linux-headers \
py3-apache-arrow=8.0.0-r0
# Copying pyarrow to site-package of actual python path. Alpine python path
# and python's docker hub path are different.
RUN mv /usr/lib/python3.10/site-packages/* \
/usr/local/lib/python3.10/site-packages/
RUN rm -rf /usr/lib/python3.10
RUN --mount=type=cache,target=/root/.cache/pip \
pip install google-cloud-bigquery==3.3.2
Update python version, alpine version and py3-apache-arrow version to install later versions. This is the latest one on the time of writing.
And make sure to remove build dependencies (build-base, linux-headers) for your release docker. I prefer multistage dockers for this.

Cannot install aws-cli from edge repository on Alpine linux

I'm trying to install aws-cli from edge repository but I cannot
https://pkgs.alpinelinux.org/package/edge/community/x86_64/aws-cli
Is it an issue with OS version? ( 3.11 / 3.12 )
If so is there a workaround?
root#6f97c6559fe9:/ # echo http://dl-cdn.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories
root#6f97c6559fe9:/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
v3.11.6-71-gb45d3b45cc [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.6-68-gf6abc2afac [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
v3.12.0-442-g76e377ea0b [http://dl-cdn.alpinelinux.org/alpine/edge/main]
OK: 16123 distinct packages available
root#6f97c6559fe9:/ # apk add aws-cli
ERROR: unsatisfiable constraints:
aws-cli (missing):
required by: world[aws-cli]
root#6f97c6559fe9:/ # apk add --update aws-cli
ERROR: unsatisfiable constraints:
aws-cli (missing):
required by: world[aws-cli]
root#6f97c6559fe9:/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.3
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
So the package page of Alpine seems to confirm that aws-cli is indeed not part of Alpine 3.11 package repository.
This said, you can install it using AWS own set of instructions, you will just need both curl and python in order to do so.
For AWS CLI v1:
apk add python curl
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Source: https://docs.aws.amazon.com/cli/latest/userguide/install-linux.html#install-linux-bundled
For AWS CLI v2, sadly, it seems Alpine is not yet supported:
nateprewitt commented on 24 Feb
Hi #firstval, it looks like you found
a response on this behavior in #4685. We're currently tracking Docker
support in #3553 which would be a prerequisite for this to work.
That said, we can definitely do better with the exceptions being
returned. We're working on getting a warning in our install script to
will alert you when the platform isn't supported.
We'll track the remaining piece for alpine support in #3553. Thanks!
Source: https://github.com/aws/aws-cli/issues/4971
Further down in #3553:
There is an official docker image for aws-cli: https://hub.docker.com/r/amazon/aws-cli
Some people got it working, but with quite a huge amount of dependancies needed (you actually need a c compiler, as it seems): https://github.com/aws/aws-cli/issues/3553#issuecomment-615149941
This would also explain why, even on Alpine 3.12, the actual package install the version 1.xx and not a 2.xx version.

nodejs v13.10.1 install on alpine

I'm trying to install nodejs version 13.10.1 on alpine docker.
What I'm trying:
FROM python:2.7-alpine
ENV ALPINE_MIRROR "http://dl-cdn.alpinelinux.org/alpine"
RUN echo "${ALPINE_MIRROR}/edge/main" >> /etc/apk/repositories
RUN apk add --no-cache nodejs-current --repository="http://dl-cdn.alpinelinux.org/alpine/edge/community"
RUN node --version
But of course It's installed the current version in edge (where it isn't v13.10.1).
So how can I found and install nodejs v13.10.1 on alpine docker?
it doesn't look like there is a package nodejs-current version 13.10.1 at branch edge in community or main. see: https://pkgs.alpinelinux.org/packages?name=nodejs-current&branch=edge&repo=community
you can build your own version - see https://stackoverflow.com/a/53389225/2087704
you could use the specific image FROM node:13.10.1-alpine

How to check if libpcap installed in Alphine docker container

I installed libpcap in my container using below docker file using docker file below. How do I make sure it was installed and working as expected?
I tried below with the hope to see libpcap
D:\work >docker exec -u 0 -it containerId sh
/app # cd /etc/apk
/etc/apk # cat repositories
http://dl-cdn.alpinelinux.org/alpine/v3.8/main
http://dl-cdn.alpinelinux.org/alpine/v3.8/community
/etc/apk #
Below is my docker file
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine AS build
# Install packages
RUN apk update
RUN apk -U --no-cache add libpcap
Running the apk info command has below output
WARNING: Ignoring APKINDEX.adfa7ceb.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.efaa1f73.tar.gz: No such file or directory
musl
busybox
alpine-baselayout
alpine-keys
libressl2.7-libcrypto
libressl2.7-libssl
libressl2.7-libtls
ssl_client
zlib
apk-tools
scanelf
musl-utils
libc-utils
ca-certificates
krb5-conf
libcom_err
keyutils-libs
libverto
krb5-libs
libgcc
libintl
libcrypto1.0
libssl1.0
libstdc++
userspace-rcu
lttng-ust
tzdata
Run docker exec command and try this
$ apk info
This will list all the installed packages in alpine.
I can see libcap in the output.
If you still can't see the package. Make sure you have run apk update before installing libcap

How can I install python modules in a docker image?

I have an image called: Image and a running container called: container.
I want to install pytorch and anaconda. What's the easiest way to do this?
Do I have to change the Dockerfile and build a new image?
Thanks a lot.
Yes, the best thing is to build your image in such a way it has the python modules are in there.
Here is an example. I build an image with the build dependencies:
$ docker build -t oz123/alpine-test-mycoolapp:0.5 - < Image
Sending build context to Docker daemon 2.56 kB
Step 1 : FROM alpine:3.5
---> 88e169ea8f46
Step 2 : ENV MB_VERSION 3.1.4
---> Running in 4587d36fa4ae
---> b7c55df49803
Removing intermediate container 4587d36fa4ae
Step 3 : ENV CFLAGS -O2
---> Running in 19fe06dcc314
---> 31f6a4f27d4b
Removing intermediate container 19fe06dcc314
Step 4 : RUN apk add --no-cache python3 py3-pip gcc python3-dev py3-cffi file git curl autoconf automake py3-cryptography linux-headers musl-dev libffi-dev openssl-dev build-base
---> Running in f01b60b1b5b9
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
(1/57) Upgrading musl (1.1.15-r5 -> 1.1.15-r6)
(2/57) Upgrading zlib (1.2.8-r2 -> 1.2.11-r0)
(3/57) Installing m4 (1.4.17-r1)
(4/57) Installing perl (5.24.0-r0)
(5/57) Installing autoconf (2.69-r0)
(6/57) Installing automake (1.15-r0)
(7/57) Installing binutils-libs (2.27-r1)
...
Note, I am installing Python's pip inside the image, so later I can download packages from pypi. Packages like numpy might require a C compiler and tool chain, so I am installing these too.
After building the packages which require the build tools chain I remove the tool chain packages:
RUN apk del file pkgconf autoconf m4 automake perl g++ libstdc++
After you have your base image, you can run your application code in
an image building on top of it:
$ cat Dockerfile
FROM oz123/alpine-test-mycoolapp
ADD . /code
WORKDIR /code
RUN pip3 install -r requirements.txt -r requirements_dev.txt
RUN pip3 install -e .
RUN make clean
CMD ["pytest", "-vv", "-s"]
I simply run this with docker.

Resources