The docker compose will remain legacy volumes and couldn't now clear them

231 views Asked by At

The docker compose will remain legacy volumes and couldn't now clear them

I tried to mount the current directory into container,

and changed its mounted name many times,

like crawler -> data-crowler -> ... root

However once I mount it, and it would remain in the container even I changed the mount volume name

What the interest is I've never use USER seluser to do anything,

But you can see the folder's owner is seluser

How could that happened ?

end of Dockerfile

EXPOSE 4444
WORKDIR  /lazy-bird
CMD ["/usr/bin/supervisord"]

docker-compose.yml

web:
  build: .
  volumes:
      - .:/lazy-bird

Root directries

drwxrwxr-x   6 seluser seluser 4.0K Jun 10 02:39 crawler/
drwxrwxr-x   6 seluser seluser 4.0K Jun 10 02:39 data-crowler/
drwxrwxr-x   6 seluser seluser 4.0K Jun 10 02:39 lazy-bird/
drwxrwxr-x   6 seluser seluser 4.0K Jun 10 02:39 root/

Dockerfile

FROM selenium/node-firefox-debug
USER root

RUN apt-get update -qqy \
    && apt-get -qqy --no-install-recommends install \
    firefox supervisor cron\
    rsyslog \
    && rm -rf /var/lib/apt/lists/*    

COPY config.json /opt/selenium/config.json

RUN apt-get update && apt-get -y upgrade && apt-get -y -qq --force-yes install \
        build-essential \
        tree \
        ruby-dev \
        vim \
        git \
        curl \
        zsh \
        sudo
# Install dependencies packages
RUN apt-get update && apt-get install -y \
  build-essential \
  openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev \
  libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev \
  autoconf libc6-dev ncurses-dev automake libtool bison nodejs

# Install Zsh
################## BEGIN INSTALLATION ######################
RUN git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh \
      && cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc \
      && chsh -s /bin/zsh

RUN sed -i -E "s/^plugins=\((.*)\)$/plugins=(\1 git git-flow ruby )/" ~/.zshrc
RUN echo "export TERM=vt100" >> /etc/zsh/zshrc

# bindkey to make HOME/END works on zsh shell
# set term=xtern make HOME/END works in vim
RUN echo "alias ls='ls --color=auto'" >> /etc/zsh/zshrc && \
    echo "alias ll='ls -halF'" >> /etc/zsh/zshrc && \
    echo "bindkey -v" >> /etc/zsh/zshrc && \
    echo "bindkey '\eOH'  beginning-of-line" >> /etc/zsh/zshrc && \
    echo "bindkey '\eOF'  end-of-line" >> /etc/zsh/zshrc && \
    echo "alias ls='ls --color=auto'" >> /etc/profile &&\
    echo "set term=xterm" >> ~/.vimrc

WORKDIR /tmp
COPY Gemfile Gemfile
RUN gem install bundler
RUN bundle install

#====================================
# Scripts to run cron job
#====================================

#ADD cron_lazy_bird /etc/crontab
RUN touch /var/log/cron.log

#====================================
# Scripts to run Selenium Standalone
#====================================

EXPOSE 4444

#USER root
# The following must match to  docker-compose.yml or the container can not launch
WORKDIR  /lazy-bird
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["/usr/bin/supervisord"]

Entry_point.sh

#!/bin/bash
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"

xvfb-run --server-args="$DISPLAY -screen 0 $GEOMETRY -ac +extension RANDR" \
    java -jar /opt/selenium/selenium-server-standalone.jar \
    -role node \
    -hub http://$HUB_1_PORT_4444_TCP_ADDR:$HUB_1_PORT_4444_TCP_PORT/grid/register \
    -browser browserName=firefox
    --background
1

There are 1 answers

1
BMW On

Answer one of your questions:

What the interest is I've never use USER seluser to do anything,

But you can see the folder's owner is seluser

How could that happened ?

You need trace the whole steps in Dockerfiles with below way, then you should know when the image is involved with USER seluser

core@core-01 ~ $ docker pull centurylink/dockerfile-from-image
core@core-01 ~ $ alias dimages="docker run -v /var/run/docker.sock:/var/run/docker.sock centurylink/dockerfile-from-image"
core@core-01 ~ $ dimages selenium/node-firefox-debug
ADD file:b43bf069650bac07b66289f35bfdaf474b6b45cac843230a69391a3ee342a273 in /
RUN echo '#!/bin/sh' > /usr/sbin/policy-rc.d    && echo 'exit 101' >> /usr/sbin/policy-rc.d     && chmod +x /usr/sbin/policy-rc.d       && dpkg-divert --local --rename --add /sbin/initctl     && cp -a /usr/sbin/policy-rc.d /sbin/initctl    && sed -i 's/^exit.*/exit 0/' /sbin/initctl         && echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup         && echo 'DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean   && echo 'APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean   && echo 'Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean      && echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/docker-no-languages      && echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes
RUN sed -i 's/^#\s*\(deb.*universe\)$/\1/g' /etc/apt/sources.list
CMD ["/bin/bash"]
MAINTAINER Selenium <[email protected]>
RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe\n" > /etc/apt/sources.list && echo "deb http://archive.ubuntu.com/ubuntu trusty-updates main universe\n" >> /etc/apt/sources.list
RUN apt-get update -qqy && apt-get -qqy --no-install-recommends install ca-certificates openjdk-7-jre-headless unzip wget && rm -rf /var/lib/apt/lists/* && sed -i 's/\/dev\/urandom/\/dev\/.\/urandom/' ./usr/lib/jvm/java-7-openjdk-amd64/jre/lib/security/java.security
RUN mkdir -p /opt/selenium && wget --no-verbose http://selenium-release.storage.googleapis.com/2.46/selenium-server-standalone-2.46.0.jar -O /opt/selenium/selenium-server-standalone.jar
RUN sudo useradd seluser --shell /bin/bash --create-home && sudo usermod -a -G sudo seluser && echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers && echo 'seluser:secret' | chpasswd
MAINTAINER Selenium <[email protected]>
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
ENV TZ=US/Pacific
RUN echo "US/Pacific" | sudo tee /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata
RUN apt-get update -qqy && apt-get -qqy install xvfb && rm -rf /var/lib/apt/lists/*
COPY file:335d2f6f9bfe311d2b38034ceab3b2ae2a1e07b9b203b330cac9857d6e17c148 in /opt/bin/entry_point.sh
RUN chmod +x /opt/bin/entry_point.sh
ENV SCREEN_WIDTH=1360
ENV SCREEN_HEIGHT=1020
ENV SCREEN_DEPTH=24
ENV DISPLAY=:99.0
USER [seluser]
CMD ["/opt/bin/entry_point.sh"]
MAINTAINER Selenium <[email protected]>
USER [root]
RUN apt-get update -qqy && apt-get -qqy --no-install-recommends install firefox && rm -rf /var/lib/apt/lists/*
COPY file:52a2a815e3bb6b85c5adfbceaabb5665b63f63ef0fb0e3f774624ee399415f84 in /opt/selenium/config.json
USER [seluser]
MAINTAINER Selenium <[email protected]>
USER [root]
RUN apt-get update -qqy && apt-get -qqy install x11vnc && rm -rf /var/lib/apt/lists/* && mkdir -p ~/.vnc && x11vnc -storepasswd secret ~/.vnc/passwd
ENV LANGUAGE=en_US.UTF-8
ENV LANG=en_US.UTF-8
RUN locale-gen en_US.UTF-8 && dpkg-reconfigure --frontend noninteractive locales && apt-get update -qqy && apt-get -qqy --no-install-recommends install language-pack-en && rm -rf /var/lib/apt/lists/*
RUN apt-get update -qqy && apt-get -qqy --no-install-recommends install fonts-ipafont-gothic xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable && rm -rf /var/lib/apt/lists/*
RUN apt-get update -qqy && apt-get -qqy install fluxbox && rm -rf /var/lib/apt/lists/*
COPY file:90e3a7f757c3df44d541b59234ad4ca996f799455eb8d426218619b244ebba68 in /opt/bin/entry_point.sh
RUN chmod +x /opt/bin/entry_point.sh
EXPOSE 5900/tcp