Alpine Docker ERROR: Unable to lock database: Permission denied ERROR: Failed to open apk database: Permission denied
For those seeing this error using a Dockerfile (and coming here via a Google search): add the following line to your Dockerfile:
USER root
Hopefully this will help anyone who is not interested in creating a new container.
If you are trying to enter into your docker container like so:
docker exec -it <containername> /bin/sh
Instead, try this:
docker exec -it --user=root <containername> /bin/sh
For those seeing this error when running through a Jenkins pipeline script (and coming hre via a Google search), use the following when starting your Docker image:
node('docker') { docker.image('golang:1.14rc1-alpine3.11').inside(' -u 0') { sh 'apk add curl' ... }}