Skip to content

Instantly share code, notes, and snippets.

@gicrisf
Created December 24, 2020 19:45
Show Gist options
  • Select an option

  • Save gicrisf/8120f6ceb692dd506be0f9d91087ebb6 to your computer and use it in GitHub Desktop.

Select an option

Save gicrisf/8120f6ceb692dd506be0f9d91087ebb6 to your computer and use it in GitHub Desktop.
Useful Alpine commands

Alpine frequent commands

Installing a package (let's show how to install python):

apk add python3 py3-pip

Specific version of a package (python or others).

  • Go to Alpine Packages;
  • Search for your specific version using filters (e.g. "python3");
  • Open the package page with the right architecture;
  • Look for the "version" field (which is composed by a number and a suffix; e.g. 3.8.6-r0);
  • Launch this command:
apk add python3<3.8.6-r0
apk add py3-pip

It will install the last useful pip for your python version.

Using = and using < make no difference.

The procedure is equivalent for every Alpine package.

Other packages you may need

curl

apk add curl 

Rust

curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

Others in the comments.

--no-cache useful for Dockers

apk add --no-cache python3 py3-pip

Why?

It allows users to install packages with an index that is updated and used on-the-fly and not cached locally:

FROM gliderlabs/alpine:3.3

RUN apk --no-cache add nginx

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

This avoids the need to use --update-cache and remove /var/cache/apk/* when done installing packages.

@gicrisf
Copy link
Author

gicrisf commented Dec 24, 2020

sudo

apk add sudo 

@gicrisf
Copy link
Author

gicrisf commented Dec 24, 2020

man

apk add man 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment