Reputation: 489
I'm having a tough time conceptually with some Docker commands. Let's suppose, not entirely hypothetically, that I'm building an image that needs --privileged
for the build. I can't figure out a way to do this. Let's further suppose that I defer the step that needs the privilege until the first run- and then I forget to specify --privileged
for that first run. Now I have a container- and docker start
won't let me specify --privileged
either. There are analogous problems with docker start
for specifying, say, a shell when I forgot to do it in the Dockerfile or with docker run
. Is there a way to rectify these problems?
Example Dockerfile:
FROM ubuntu:14.04.5
ENV TERM linux
ENV DEBIAN_FRONTEND noninteractive
ENV REDDIT_USER reddit
RUN apt-get update
RUN apt-get install -y aptitude
RUN aptitude update
RUN aptitude upgrade -o Aptitude::Delete-Unused=1 -y
RUN aptitude install -y vim-nox git screen zsh wget software-properties-common
RUN git clone https://github.com/reddit-archive/reddit
RUN adduser --disabled-password --gecos "" reddit
# can't run this in build; instead, start the image with --privileged and then run the script manually
#RUN echo "y" | ./reddit/install-reddit.sh
CMD ["/bin/bash"]
EXPOSE 80
Upvotes: 1
Views: 169
Reputation: 3215
You can't run as a privileged during builds, unless you use buildx. What you can do, however, is to make your changes on a container with docker run --privileged
, then use docker commit
to turn it back into an image:
$ docker run -ti <image>
# do your thing...
$ docker commit <container id> final-image:version
Upvotes: 1