Be safe, don't use root
Not giving access to the root user in your images makes images more foolproof, as users only have access to what's relevant to the use case you intended for the image. Additionally, it is one of the best options to increase their security. We've built an image for you from the following Dockerfile, which tries to install python3 as soon as you start it.
FROM ubuntu
RUN useradd -m repl
USER repl
CMD apt-get install python3
Let's see what happens if we try to install python3 at startup as the repl user.
This exercise is part of the course
Introduction to Docker
Exercise instructions
- Use
docker
to run therepl_try_install
image.
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
