I'm working with yocto and I'm trying to build my custom image using this a base: yocto-ubuntu-20.04.
I have this simple docker file:
FROM reliableembeddedsystems/yocto:ubuntu-20.04-base
RUN apt-get update
But I'm getting permissions error when building:
user@user$ sudo docker build .
[...]
------
> [2/2] RUN apt-get update:
0.214 Reading package lists...
0.753 E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
0.753 E: Unable to lock directory /var/lib/apt/lists/
------
Dockerfile:2
--------------------
1 | FROM reliableembeddedsystems/yocto:ubuntu-20.04-base
2 | >>> RUN apt-get update
3 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update" did not complete successfully: exit code: 100
If I add sudo
to RUN apt-get update
line I get a different error asking for password:
> [2/2] RUN sudo apt-get update:
0.207 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
------
Dockerfile:2
--------------------
1 | FROM reliableembeddedsystems/yocto:ubuntu-20.04-base
2 | >>> RUN sudo apt-get update
3 |
--------------------
ERROR: failed to solve: process "/bin/sh -c sudo apt-get update" did not complete successfully: exit code: 1
Which is the correct way to work with it?
Another question: if run a container using the base image, I notice that I can use sudo. But, how am I supposed to know the password? Is it okay to use sudo
in here?
It seems that the base image sets a user other than root. This can be fixed using:
FROM reliableembeddedsystems/yocto:ubuntu-20.04-base
USER root
RUN apt-get update