Inside my dockerfile I have:
FROM ubuntu:latest
FROM python:latest
RUN sudo apt-get update
RUN apt-get install nmap
But I have a problem where the last line doesn’t work because of sudo, how may I fix this?
Inside my dockerfile I have:
FROM ubuntu:latest
FROM python:latest
RUN sudo apt-get update
RUN apt-get install nmap
But I have a problem where the last line doesn’t work because of sudo, how may I fix this?
2
Answers
The following works for me:
-y
means automatic "yes" answer to all prompts and runs non-interactively.Since your first FROM statement doesn’t do anything and you’re already running as root, you can change your Dockerfile to
Build and run with
Now you’re in a shell in the container. You can now run
whoami
to verify that you’re running as root and you can run nmap.