Apk add alpine desktop ошибка

Hey there!

I’m new to docker, and new to alpine in general. I love the work you’ve done and think it’s fantastic for a container-centric future. I’m running into issues using apk update and apk add, in addition to apk-install using the base image provided by gliderlabs/docker-alpine:3.1 (and :3.2, for that matter).

Using a Dockerfile that looks like:

FROM gliderlabs/alpine:3.1
RUN apk --update add mysql-client
ENTRYPOINT ["mysql"]

I get this error:

Step 1 : RUN apk --update add mysql-client
 ---> Running in 9129d237031e
fetch http://dl-4.alpinelinux.org/alpine/v3.1/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-4.alpinelinux.org/alpine/v3.1/main: IO ERROR
WARNING: Ignoring APKINDEX.689bb31a.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
  mysql-client (missing):
    required by: world[mysql-client]
The command '/bin/sh -c apk --update add mysql-client' returned a non-zero code: 1

After doing some research (which was rather annoying, as the Alpine Linux wiki is down — yay google cache and archive.org), everything I was attempting to do seemed to be correct.

Logically, I figured it was an issue with the repository sources. No problem, let’s open up /etc/apk/repositores.

Whoops! It looks like by default, you only have http://dl-4.alpinelinux.org/alpine/v3.1/main. I ran into #15 and discovered a list of mirrors which have been most helpful. It currently looks like the following sources are currently failing:

http://dl-3.alpinelinux.org/alpine/v3.1/main
http://dl-4.alpinelinux.org/alpine/v3.1/main

1, 2, and 5 are peachy. I propose adding mirrors to the repositories included in your base image. While it’s easy enough for people to add the mirrors themselves, it will save time in the long run, especially for newer users.

Edit (next day): 3 and 4 back up. It would seem the logical choice to add all five mirrors by default.

Итак, что же мы знаем об Alpine Linux и зачем его устанавливать? Во-первых, он базируется на musl и BusyBox, во-вторых, это единственный независимый дистрибутив Linux предоставляющий безопасность в общих целях. Его разработка была предопределена концепцией обеспечения безопасности, а для защиты от вредоносного кода было решено использовать PaX и SSP.

Стоит отметить его необычно неприхотливые требования к ресурсам системы. Пакеты используются apk, но некоторые придется установить самостоятельно. Руководство, конечно же, присутствует на сайте дистрибутива, которому необходимо не более 8 МБ, а минимальная установка на диск требует не более 130 МБ свободного места. Для управления пакетами в Alpine используется apk. И некоторых пакетов, которые Вам будут нужны, по умолчанию не будет в Alpine.

Шаг 1. Загрузка образа

Переходим по этой ссылке https://www.alpinelinux.org/downloads/ и качаем образ:

Нам нужен STANDARD.

Шаг 2. Запись образа

Все как обычно, — если у вас Linux, то качаем Unebootin; если у вас Windows,  то качаем Rufus. Ссылки предоставил.

Шаг 3. Настройка BIOS

Перезагружаем компьютер и заходим в BIOS. Нам надо зайти во вкладку Boot и указать в пункте 1st Boot Device вашу флешку. Затем сохраните настройки и перезагрузите компьютер.

Шаг 4. Начало установки

Заранее говорю, что все делается через командную строку.

Пишем для входа в командную оболочку:

root

Далее выполняем команду:

setup-alpnie

Таким образом мы запускаем процесс установки

Шаг 5. Раскладка клавиатуры

Выбираем раскладку из списка. В моем случае это:

us

Жмем далее и снова пишем:

us

Шаг 6. Имя компьютера

При указании имени компьютера обратите внимание на то, что следует использовать числа и символы нижнего регистра. Например, имя Noma я не смог указать, зато имя noma вполне проходит по параметрам.

Шаг 7. Настройка сети

Сразу же после указания имени хоста нам предложат настройки, связанные с интернетом. Если у вас проводной интернет по DHCP, их просто пропускаем нажатием Enter. Все это можно настроить уже потом непосредственно в установленной системе.

Шаг 8. Пароль пользователя

Указываем пароль для суперпользователя. Если он 6-значный, например, то вы получите предупреждение о том, что пароль слишком слабый, но это не мешает установке.

Шаг 9. Настройка прокси

Далее вы можете установить прокси или просто пропустить. В моем случае я просто нажал Enter и пропустил этот пункт, так как все это тоже можно будет потом настроить, при необходимости.

Шаг 10. Выбор зеркала репозиториев

Вам дадут список зеркал, если вы этого не сделаете, то система будет проверять каждое и самостоятельно выберет наиболее подходящее.

Примечание для жителей Украины. Если вы не укажите зеркало, то рискуете попасть на Yandex, а с ним установка не получится, так как компания под санкциями. В вашем случае просто выберете любое другое.

Шаг 11. Настройка SSH

Если вы хотите, то можете установить и ssh сервер. И снова, на данном этапе это не является необходимым, и вы всегда сможете его поднять позже.

Шаг 12. Выбор места установки

Система предложит выбрать любой из доступных дисков для установки ОС. Я указываю следующее:

sda

Далее вам надо выбрать для чего будет использоваться этот диск. Так как это системный диск, то я выбираю:

sys

Получаем предупреждение о том, что все данные с выбранного диска будут удалены. Впрочем, ничего удивительного. Пишем:

y

Шаг 13. Завершение установки

Когда установка Alpine Linux завершится, система попросит о перезагрузке. Для этого извлекаем носитель на котором система и перезагружаемся командой:

reboot

Шаг 14. Вход в систему

Пишем в логине:

root

Далее пишем пароль, который ранее задавали.

Шаг 15. Установка редактора nano

Так как у нас нет редактора, то мы установим. Это будет редактор Nano. Сделаем это с помощью команды:

apk add nano

Шаг 16. Редактирование файла с репозиториями и обновление

Теперь нам надо отредактировать файл репозиториев. Это позволит нам обновить систему и продолжить установку. Пишем:

/etc/apk/repositories

Чтобы получить доступ к репозиторию сообщества надо раскомментиовать третью строку:

#http://dl-cdn.alpinelinux.org/alpnie/v3.10/community

Для этого удалите # перед ней. После жмем ctrl+o -> Enter -> ctrl+x. После всего пишем команду:

apk update

Шаг 17. Установка графического интерфейса

Выполняем команду:

setup-xorg-base

Теперь выполняем команду:

apk add alpine-desktop

Шаг 18. Устанавливаем окружение xfce4

Выполняем команду:

apk add xfce4

Шаг 19. Устанавливаем файловый менеджер

Выполняем команду:

apk add thunar-volman

Достаточно тривиально, но проверено.

Шаг 20. Набор тем и иконок

Выполняем команду:

apk add Faenza-icon-theme

Шаг 21. Устанавливаем менеджер входа

Выполняем команду:

apk add slim

Так как система является легковесной, то будем работать в направлении её преимуществ. Это ответ на вопрос: А почему Slim?.

Шаг 22. Запуск сервиса DBus

Чтобы приложения могли между собой взаимодействовать, нам надо запустить сервис межпроцессорного взаимодействия (IPC). Выполняем команду:

rc-service dbus start

Работает, отлично. Теперь добавим его в автозагрузку?

Выполняем команду:

rc-update add dbus

Шаг 23. Завершение установки.

Выполняем команду:

reboot

Это позволит нам перезагрузить устройство и войти в систему с графическим интерфейсом.

В поле username пишем root и указываем раннее заданный пароль. Ну а дальше рабочий стол.

Теперь вы знаете как установить Alpine Linux, а также как минимально настроить систему, так, чтобы с ней можно было работать.

Creative Commons License

Статья распространяется под лицензией Creative Commons ShareAlike 4.0 при копировании материала ссылка на источник обязательна .

I’m trying to install packages in a docker image based on alpine. The host system is CentOS system, system-release: CentOS Linux release 7.6.1810 (Core).

Here’s what I do:

# docker run -td alpine:3.9
abbd2da62ed51047de063ef06e2422ae22ff77788fd70a626ad3a6b85856a3af.
# docker exec -it abbd2
/ # apk add bash
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl- 
cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/5) Installing ncurses-terminfo-base (6.1_p20190105-r0)
(2/5) Installing ncurses-terminfo (6.1_p20190105-r0)
(3/5) Installing ncurses-libs (6.1_p20190105-r0)
(4/5) Installing readline (7.0.003-r1)
ERROR: readline-7.0.003-r1: Permission denied
(5/5) Installing bash (4.4.19-r1)
ERROR: bash-4.4.19-r1: Permission denied
2 errors; 13 MiB in 17 packages

This corresponds to a Dockerfile like this:

FROM alpine:3.9
RUN apk add bash

Why do I get permission errors while trying to install the package (using bash here as an example)?

How can I get the package to install?

ctrl-alt-delor's user avatar

asked Mar 22, 2019 at 7:45

Wilbert's user avatar

3

Blocked by Proxy

Turns out the problem was that our Proxy did not allow downloads from dl-cdn.alpinelinux.org.

The error message that alpine gives could be clearer, but anyway: Allowing downloads from that URL made the apk add run through without problems.

answered Mar 22, 2019 at 12:54

Wilbert's user avatar

WilbertWilbert

1611 silver badge7 bronze badges

I want to install Alpine packages like python in a Docker image, but when I run docker build - < Dockerfile (or build using IntelliJ) I get

ERROR: unsatisfiable constraints:
  /bin/sh (virtual):
    provided by: busybox
    required by:
                 alpine-baselayout-3.1.0-r0[/bin/sh]
                 alpine-baselayout-3.1.0-r0[/bin/sh]
The command '/bin/sh -c apk add --update python' returned a non-zero code: 2

I am using the following Dockerfile which I derived from the docs at github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md

FROM gliderlabs/alpine:latest
RUN apk add --update python

Same error when using the docker image interactively

When I use docker run -it gliderlabs/alpine:latest /bin/sh and then apk add --update python or apk add python I get the same error.

When I do apk update I get OK: 9543 distinct packages available, but when I do apk upgrade I get the same error.

System information

I am using Arch Linux 4.19.8.

The Image ID of gliderlabs/alpine:latest is sha256:673b8178133a04ed1de21d6cf1a729f8aaf9469d4550005ede89e7142efd9459.

The output of docker run gliderlabs/alpine:latest which apk is /sbin/apk.

The docker version is 18.09.0-ce.

Relevant other information

Docker Alpine /bin/sh apk not found looks similar (though on CentOS) but has no resolution, one comment links to:

/bin/sh: 1: apk: not found while creating docker image but the answer is to switch to apk which I’m doing already (the docs are pretty clear about this).

Docker: Using apt-key with alpine image also suggests to use apk add which is what I’m doing.

Edit

As suggested by @larsks, you can run apk search --update python | grep '^python' and it shows me that I have python3-3.6.6-r0 availabe but not python. However, when I try apk add python3-3.6.6-r0 I get

ERROR: unsatisfiable constraints:
  python3-3.6.6-r0 (missing):
    required by: world[python3-3.6.6-r0]
  /bin/sh (virtual):
    provided by: busybox
    required by: alpine-baselayout-3.1.0-r0[/bin/sh] alpine-baselayout-3.1.0-r0[/bin/sh]

Also, this wouldn’t explain why apk upgrade fails with the same error as apk add python.

When I try apk add --update python3 I get

fetch http://alpine.gliderlabs.com/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://alpine.gliderlabs.com/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  /bin/sh (virtual):
    provided by: busybox
    required by: alpine-baselayout-3.1.0-r0[/bin/sh] alpine-baselayout-3.1.0-r0[/bin/sh]

For the old hardware, I would much rather find new ways to use it, rather than just throwing it away. The Alpine Linux is a non-comercial distribution known for its small resource requirements, simplicity and security.

The version I have used for my install is 3.11.3. However, the purpose of this article is to provide a rather general overview of what you need to do. So the intention is to use the latest versions for everything, even if this might lead to some different here and there, as compared to the following content.

You can find more information on the project’s webpage: https://www.alpinelinux.org/about/

What should you do first?

  • Learn how to get into the BIOS of your machine and make sure you can boot from a USB stick. If this is not possible, then you must find an alternative to creating the installation media;
  • Check if your machine supports x64 architecture, so that you know which version of the install kit to download;
  • Obviously, you should have another device present, for researching situations not described in this tutorial or create new installation media etc.

Create a bootable image of Alpine Linux

Which version of alpine linux should you download for your bare metal install? For a rather normal install you should probably download the standard x64 version.
https://alpinelinux.org/downloads/

We will use balenaEtcher (https://www.balena.io/etcher/) to create the bootable USB stick. It has a quite intuitive interface, very accesible to everybody. The main thing to take into account is that it will delete all the data on your USB stick, so be sure this will not affect you.

Boot from the USB stick and install

A basic requirement is to be able to boot from a USB device. Depending on your machine, you might need to make some changes in your BIOS.

A couple of great tutorials installing Alpine with xfce as a virtual machine can be found at:

  • https://www.youtube.com/watch?v=1_bsycXrFcI
  • https://www.youtube.com/watch?v=HwiDmLXUY5U

The operating system

I had multiple attempts to install the operating system, mainly because trouble setting up the network connection. However, with a little bit of patience and luck, you should be fine.

As the operating system loads from the USB stick, follow this:

  • use root as username to login;
  • setup-alpine and follow the default options as much as possible;
  • remove the USB stick;
  • reboot

Small introduction

  • Alpine apk does not have anything to do with the Android world apk files;
  • rc-service <name> start will immediately start your package;
  • rc-update add <name> will add your package to the default runlevel;
  • rc-update del <name> will prevent the package to start.

Sources:

  • https://wiki.alpinelinux.org/wiki/SLiM
  • https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management

XFCE as grapical interface

  • apk update
  • apk add nano
    nano is a very comfortable editor in the linux world. As opposed to vi which is already installed, nano has a rather more beginner friendly interface.
  • nano /etc/apk/repositories
    and ensure that /community is not commented.
  • setup-xorg-base
  • apk add alpine-desktop
  • apk add xfce4
  • reboot

Other useful packages:

  • apk add git
  • apk add curl

At this point, you have two options. The first one is to manually start the desktop environment by using exec startxfce4 every time you want the desktop environment. The second is to continue with this sequence of commands, to have it start automatically.

  • apk add thunar-volman udisks2
    This is an extension for the Thunar file manager, which enables automatic management of removable drives;
  • apk add faenza-icon-theme
    As the name states, this is a nice icon theme;
  • apk add slim
    slim is a lightweight and simple to configure login manager;
  • rc-service dbus start
  • rc-update add dbus
  • rc-service udev start
  • rc-update add udev
  • rc-update add slim
  • reboot

Sources:

  • https://wiki.alpinelinux.org/wiki/XFCE_Setup
  • https://askubuntu.com/questions/614543/how-to-get-xfce4-desktop-at-startup-without-the-bloat

Further customisation and commands

Set a network name

For accesting the host easier inside the network, you can give the computer a name. I think I went around with the solution a bit, but I have named my computer shorty with the following process:

  • echo "shorty" > /etc/hostname
  • hostname -F /etc/hostname
  • setup-interfaces
    This will start helper which will guide you though configuring the network
  • reboot

Source:

  • https://wiki.alpinelinux.org/wiki/Configure_Networking
  • https://wiki.alpinelinux.org/wiki/Alpine_setup_scripts

Change the password for a user

echo "root:password" | chpasswd

This command will change the password for user root to password.

Connect with root via ssh

First and most important: this is not a safe practice, you should not use the root user directly. However, I use my computer for testing inside my home network. And it is more comfortable to do more settings via the command line, from my workstation.

So, use the following commands:

  • nano /etc/ssh/sshd_config
  • Ensure the following is present: PermitRootLogin yes

Source: https://superuser.com/questions/539139/putty-password-access-denied

Zsh and starship

Zsh is one of the first things I install, wherever possible. This alpine installation will be no exception. However, on this install I had a little trouble using .antigen and while trying to fix it, I have stumbled upon starship. This apparently packs some interesting functionality, I had to try it:

  • apk add zsh
  • curl -fsSL https://starship.rs/install.sh | bash

Add antigen:

  • mkdir ~/.antigen/ && cd ~/.antigen
  • curl -L git.io/antigen > antigen.zsh
  • nano ~/.zshrc and add your configuration.

An example configuration is:

eval "$(starship init zsh)"

source ~/.antigen/antigen.zsh

antigen use oh-my-zsh
antigen bundle git
antigen bundle heroku
antigen bundle pip
antigen bundle lein
antigen bundle command-not-found

antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-autosuggestions

# antigen theme bira

antigen apply

To update the default shell for a user, you can do the following:

  • sudo nano /etc/passwd
  • replace /bin/bash with /bin/zsh for whichever user you want to use this shell as default.

Sources:

  • https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH
  • https://starship.rs/

Create a new sudo user

It is well known that using root for a linux system is discouraged. Use the following steps to create a new user – newuser – and assign elevated privileges to it:

  • adduser newuser
  • addgroup sudo
  • addgroup newuser sudo
  • nano /etc/sudoers and add: %sudo ALL=(ALL) ALL

You can use: su newuser to switch to the new user and sudo ls -la as a test command. If something went wrong, you will see a message similar to: newuser is not in the sudoers file.  This incident will be reported.

Otherwise, the list of expected files and folders will be displayed.

Sources:

  • https://wiki.alpinelinux.org/wiki/Setting_up_a_new_user
  • https://www.linode.com/docs/tools-reference/custom-kernels-distros/install-alpine-linux-on-your-linode/
  • https://www.cyberciti.biz/faq/how-to-add-and-delete-users-on-alpine-linux/

I’ve been running into a similar infuriating issue. Sometimes, I get IO errors installing packages with apk. It seems dependent on how much IO is being performed: an image installing eleven packages only rarely gets these, all I have to do is run build again, while an image installing 86 packages never succeeds.

 $ docker build .
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM docker:latest
 ---> fd7e073eb60f
Step 2/2 : RUN apk update && apk add     openssh-client     openjdk8-jre     terraform     libc-dev     py-pip     gnupg     make     curl     bash     git     go     jq
 ---> Running in 6f1483a689d8
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
v3.8.1-62-ga10c10dd7d [http://dl-cdn.alpinelinux.org/alpine/v3.8/main]
v3.8.1-61-g338ad9f579 [http://dl-cdn.alpinelinux.org/alpine/v3.8/community]
OK: 9546 distinct packages available
(1/86) Installing ncurses-terminfo-base (6.1_p20180818-r1)
(2/86) Installing ncurses-terminfo (6.1_p20180818-r1)
ERROR: Failed to create usr/share/terminfo/x/xenix: I/O error
ERROR: ncurses-terminfo-6.1_p20180818-r1: IO ERROR
(3/86) Installing ncurses-libs (6.1_p20180818-r1)
(4/86) Installing readline (7.0.003-r0)
(5/86) Installing bash (4.4.19-r1)
Executing bash-4.4.19-r1.post-install
(6/86) Installing nghttp2-libs (1.32.0-r0)
...

…sometimes these errors are instead as such:

ERROR: ncurses-terminfo-6.1_p20180818-r1: BAD archive

Here’s a Dockerfile that will reliably produce this for me:

FROM docker:latest

RUN apk update && apk add 
    openssh-client 
    openjdk8-jre 
    terraform 
    libc-dev 
    py-pip 
    gnupg 
    make 
    curl 
    bash 
    git 
    go 
    jq

Quite certain my NVMe drive is fine as it is only a few weeks old and I’m seeing no other IO issues or errors anywhere else.

Here’s what I believe to be all the relevant system information::

DISTRIB_DESCRIPTION="Ubuntu 18.10"

Docker version 18.09.0, build 4d60db4

Linux my-pizza 4.18.0-11-generic #12-Ubuntu SMP Tue Oct 23 19:22:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

I’m trying to install packages in a docker image based on alpine. The host system is CentOS system, system-release: CentOS Linux release 7.6.1810 (Core).

Here’s what I do:

# docker run -td alpine:3.9
abbd2da62ed51047de063ef06e2422ae22ff77788fd70a626ad3a6b85856a3af.
# docker exec -it abbd2
/ # apk add bash
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl- 
cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/5) Installing ncurses-terminfo-base (6.1_p20190105-r0)
(2/5) Installing ncurses-terminfo (6.1_p20190105-r0)
(3/5) Installing ncurses-libs (6.1_p20190105-r0)
(4/5) Installing readline (7.0.003-r1)
ERROR: readline-7.0.003-r1: Permission denied
(5/5) Installing bash (4.4.19-r1)
ERROR: bash-4.4.19-r1: Permission denied
2 errors; 13 MiB in 17 packages

This corresponds to a Dockerfile like this:

FROM alpine:3.9
RUN apk add bash

Why do I get permission errors while trying to install the package (using bash here as an example)?

How can I get the package to install?

I want to install Alpine packages like python in a Docker image, but when I run docker build - < Dockerfile (or build using IntelliJ) I get

ERROR: unsatisfiable constraints:
  /bin/sh (virtual):
    provided by: busybox
    required by:
                 alpine-baselayout-3.1.0-r0[/bin/sh]
                 alpine-baselayout-3.1.0-r0[/bin/sh]
The command '/bin/sh -c apk add --update python' returned a non-zero code: 2

I am using the following Dockerfile which I derived from the docs at github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md

FROM gliderlabs/alpine:latest
RUN apk add --update python

Same error when using the docker image interactively

When I use docker run -it gliderlabs/alpine:latest /bin/sh and then apk add --update python or apk add python I get the same error.

When I do apk update I get OK: 9543 distinct packages available, but when I do apk upgrade I get the same error.

System information

I am using Arch Linux 4.19.8.

The Image ID of gliderlabs/alpine:latest is sha256:673b8178133a04ed1de21d6cf1a729f8aaf9469d4550005ede89e7142efd9459.

The output of docker run gliderlabs/alpine:latest which apk is /sbin/apk.

The docker version is 18.09.0-ce.

Relevant other information

Docker Alpine /bin/sh apk not found looks similar (though on CentOS) but has no resolution, one comment links to:

/bin/sh: 1: apk: not found while creating docker image but the answer is to switch to apk which I’m doing already (the docs are pretty clear about this).

Docker: Using apt-key with alpine image also suggests to use apk add which is what I’m doing.

Edit

As suggested by @larsks, you can run apk search --update python | grep '^python' and it shows me that I have python3-3.6.6-r0 availabe but not python. However, when I try apk add python3-3.6.6-r0 I get

ERROR: unsatisfiable constraints:
  python3-3.6.6-r0 (missing):
    required by: world[python3-3.6.6-r0]
  /bin/sh (virtual):
    provided by: busybox
    required by: alpine-baselayout-3.1.0-r0[/bin/sh] alpine-baselayout-3.1.0-r0[/bin/sh]

Also, this wouldn’t explain why apk upgrade fails with the same error as apk add python.

When I try apk add --update python3 I get

fetch http://alpine.gliderlabs.com/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://alpine.gliderlabs.com/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  /bin/sh (virtual):
    provided by: busybox
    required by: alpine-baselayout-3.1.0-r0[/bin/sh] alpine-baselayout-3.1.0-r0[/bin/sh]

Hey there!

I’m new to docker, and new to alpine in general. I love the work you’ve done and think it’s fantastic for a container-centric future. I’m running into issues using apk update and apk add, in addition to apk-install using the base image provided by gliderlabs/docker-alpine:3.1 (and :3.2, for that matter).

Using a Dockerfile that looks like:

FROM gliderlabs/alpine:3.1
RUN apk --update add mysql-client
ENTRYPOINT ["mysql"]

I get this error:

Step 1 : RUN apk --update add mysql-client
 ---> Running in 9129d237031e
fetch http://dl-4.alpinelinux.org/alpine/v3.1/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-4.alpinelinux.org/alpine/v3.1/main: IO ERROR
WARNING: Ignoring APKINDEX.689bb31a.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
  mysql-client (missing):
    required by: world[mysql-client]
The command '/bin/sh -c apk --update add mysql-client' returned a non-zero code: 1

After doing some research (which was rather annoying, as the Alpine Linux wiki is down — yay google cache and archive.org), everything I was attempting to do seemed to be correct.

Logically, I figured it was an issue with the repository sources. No problem, let’s open up /etc/apk/repositores.

Whoops! It looks like by default, you only have http://dl-4.alpinelinux.org/alpine/v3.1/main. I ran into #15 and discovered a list of mirrors which have been most helpful. It currently looks like the following sources are currently failing:

http://dl-3.alpinelinux.org/alpine/v3.1/main
http://dl-4.alpinelinux.org/alpine/v3.1/main

1, 2, and 5 are peachy. I propose adding mirrors to the repositories included in your base image. While it’s easy enough for people to add the mirrors themselves, it will save time in the long run, especially for newer users.

Edit (next day): 3 and 4 back up. It would seem the logical choice to add all five mirrors by default.

I’m trying to install packages in a docker image based on alpine. The host system is CentOS system, system-release: CentOS Linux release 7.6.1810 (Core).

Here’s what I do:

# docker run -td alpine:3.9
abbd2da62ed51047de063ef06e2422ae22ff77788fd70a626ad3a6b85856a3af.
# docker exec -it abbd2
/ # apk add bash
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl- 
cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/5) Installing ncurses-terminfo-base (6.1_p20190105-r0)
(2/5) Installing ncurses-terminfo (6.1_p20190105-r0)
(3/5) Installing ncurses-libs (6.1_p20190105-r0)
(4/5) Installing readline (7.0.003-r1)
ERROR: readline-7.0.003-r1: Permission denied
(5/5) Installing bash (4.4.19-r1)
ERROR: bash-4.4.19-r1: Permission denied
2 errors; 13 MiB in 17 packages

This corresponds to a Dockerfile like this:

FROM alpine:3.9
RUN apk add bash

Why do I get permission errors while trying to install the package (using bash here as an example)?

How can I get the package to install?

I want to install Alpine packages like python in a Docker image, but when I run docker build - < Dockerfile (or build using IntelliJ) I get

ERROR: unsatisfiable constraints:
  /bin/sh (virtual):
    provided by: busybox
    required by:
                 alpine-baselayout-3.1.0-r0[/bin/sh]
                 alpine-baselayout-3.1.0-r0[/bin/sh]
The command '/bin/sh -c apk add --update python' returned a non-zero code: 2

I am using the following Dockerfile which I derived from the docs at github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md

FROM gliderlabs/alpine:latest
RUN apk add --update python

Same error when using the docker image interactively

When I use docker run -it gliderlabs/alpine:latest /bin/sh and then apk add --update python or apk add python I get the same error.

When I do apk update I get OK: 9543 distinct packages available, but when I do apk upgrade I get the same error.

System information

I am using Arch Linux 4.19.8.

The Image ID of gliderlabs/alpine:latest is sha256:673b8178133a04ed1de21d6cf1a729f8aaf9469d4550005ede89e7142efd9459.

The output of docker run gliderlabs/alpine:latest which apk is /sbin/apk.

The docker version is 18.09.0-ce.

Relevant other information

Docker Alpine /bin/sh apk not found looks similar (though on CentOS) but has no resolution, one comment links to:

/bin/sh: 1: apk: not found while creating docker image but the answer is to switch to apk which I’m doing already (the docs are pretty clear about this).

Docker: Using apt-key with alpine image also suggests to use apk add which is what I’m doing.

Edit

As suggested by @larsks, you can run apk search --update python | grep '^python' and it shows me that I have python3-3.6.6-r0 availabe but not python. However, when I try apk add python3-3.6.6-r0 I get

ERROR: unsatisfiable constraints:
  python3-3.6.6-r0 (missing):
    required by: world[python3-3.6.6-r0]
  /bin/sh (virtual):
    provided by: busybox
    required by: alpine-baselayout-3.1.0-r0[/bin/sh] alpine-baselayout-3.1.0-r0[/bin/sh]

Also, this wouldn’t explain why apk upgrade fails with the same error as apk add python.

When I try apk add --update python3 I get

fetch http://alpine.gliderlabs.com/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://alpine.gliderlabs.com/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  /bin/sh (virtual):
    provided by: busybox
    required by: alpine-baselayout-3.1.0-r0[/bin/sh] alpine-baselayout-3.1.0-r0[/bin/sh]

Problem:

You are trying to install an apk package using e.g.

apk install python

but you see this error message:

ERROR: 'install' is not an apk command. See 'apk --help'.

Solution:

Use apk add instead of apk install to install packages on Alpine Linux !

So instead of

apk install python

use

apk add python

If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow

Понравилась статья? Поделить с друзьями:
  • App store ошибка 1001
  • Api ошибки список
  • Api ошибка валидации какой код
  • App store ios 12 ошибка
  • Api ошибка 429