Search code examples
dockerfilealpine-linuxapt

how to use apt/sudo in alpine-based docker image


I am currently writing a docker file that has to be based on alpine (the top line is FROM alpine:latest. I wish to use tools such as sudo and curl (by running a shell script from the dockerfile) which are normally avaialble on linux/mac, and to do this I have tried running RUN apt update && apt-get install sudo -y - however these don't seem to be available with alpine. Would anyone know how to get apt after basing off alpine, or another method of obtaining basic tools like sudo and curl? I've tried using apk (e.g. RUN apk add apt-get) but I always get an error like apt-get (no such package):.


Solution

  • another method of obtaining basic tools like sudo and curl?

    I believe alpine uses apk instead of apt

    Try something like this to install basic tools like curl and sudo

    RUN apk add curl sudo