I have created custom docker image using Ubuntu 16.04 xenial as base image, and installed JDK-1.8 and MY-SQL layer on it. Following is sample snap-shot of my Dockerfile to create image.
# Use 0.9.19 as this is the last tag that uses Ubuntu 16.04 xenial
FROM phusion/baseimage:0.9.19
# Set correct environment variables.
ENV HOME /root
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
# Maintained by Abhi
MAINTAINER Abhishek <[email protected]>
# Set the locale. Default locale causes some Perl regexes to fail.
# http://jaredmarkell.com/docker-and-locales/
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV MYSQL_PWD pass123admin
# Fix warning "debconf: delaying package configuration, since apt-utils is not installed " during build.
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
# The base Ubuntu images don't come with sudo, so Add sudo
RUN apt-get update && apt-get install -y sudo
# Install JDK 8
RUN echo "deb http://debian.opennms.org/ stable main" >> /etc/apt/sources.list \
&& curl -sS http://debian.opennms.org/OPENNMS-GPG-KEY | apt-key add - \
&& apt-get update -y \
&& echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections \
&& apt-get install oracle-java8-installer -y
## Install all software available via apt-get
RUN echo "mysql-server mysql-server/root_password password $MYSQL_PWD" | debconf-set-selections \
&& echo "mysql-server mysql-server/root_password_again password $MYSQL_PWD" | debconf-set-selections \
&& apt-get update -y && apt-get install -y \
mysql-server
Everything works as expected for building the image and creating the container.
But whenever I tried to remove the Docker-Container created using this image. It is not removing MY-SQL layer within it.
I used $ docker rm mycontainer mycontainer command to delete the container created using above image.
But when I recreated the container using above image (also uses --force-recreate option), I was able to see my previous data in MySql Database. This means $ docker rm can not remove the container completely with underlying layers.
Is there a way to delete completely remove docker-container including it's underlying layers of MySQL or JDK?
Thanks in advance.