docker stop && docker rm doesn't really get rid of my container

I have some weird behaviour when working with the postgres image.

I’ve created a script which is mounted into /docker-entrypoint-initdb.d and using single-user mode to initialise the database.

  • Get docker run command for container
  • how can i access my application deployed on my docker wildfly images
  • docker 1.7.0 under ubuntu14.04,can not run a container,error message “device or resourcebusy ”
  • How do I set the configuration of the port 8000 on nginx with docker?
  • Docker webpack dev server
  • pyftpdlib Networkprotocol Error
  • However, when I update the script, run

    docker stop postgres_db
    docker rm postgres_db
    

    and than start a new container, the database is the old one. It doesn’t change.

    I’m using vagrant box-cutter/ubuntu1404-docker and when I run

    vagrant destroy -f
    vagrant up
    

    and than recreate the new docker container, the changes are applied.

    Why doesn’t it work when I just remove the old container and start a new one? Where does docker keep it’s cache which I could purge to really get a new image?

    Update:

    The exact docker file I’m using is a small extension to the original one. It just installs the orafce plugin link, content:

    FROM postgres:9.4
    
    RUN apt-get update && \
        apt-get install -y postgresql-9.4-orafce && \
        rm -rf /var/lib/apt/lists/*
    

    the command I use to start a new container is:

    docker run --name="postgres_db" \
               --restart="always" \
               -e POSTGRES_PASSWORD=PostgresPassword \
               -p 5432:5432 \
               -v /data:/var/lib/postgresql/data \
               -v /vagrant/container_data/init_scripts:/docker-entrypoint-initdb.d \
               -v /vagrant/container_data/tmp:/tmp \
               -d grmanit/postgres
    

    the init_scripts folder contains one script which creates a new database and a new user.

    Clarifications:

    When I change the script in my init_scripts folder, for instance modify the database name, and than stop+remove the old container and start a new one, it doesn’t have any effect.

    When I change the password of postgres, which is set as an environment variable in the docker run command (in this example it’s PostgresPassword) and again stop+remove the old container and than start a new one with the new environment variable, it again doesn’t have any effect. I still need to use the old password to connect to the db and the new one wouldn’t work.

    But when I destroy the VM and start it up again, I have the configurations which I had defined before. However changing them again needs me to destroy and restart the VM which takes much longer than just destroying a docker container and starting up a new one.

  • Debugging Django on Docker on Vagrant with IDE
  • Error: “error creating aufs mount to” when building dockerfile
  • Docker Container Based on Non Existing Image?
  • docker cp not working
  • Running Wildfly Swarm with KeyCloak on docker image
  • Separate specific configuration in Dockerfile
  • One Solution collect form web for “docker stop && docker rm doesn't really get rid of my container”

    You get a new container, but -v /data:/var/lib/postgresql/data mounts the /data directory of the host into the container, making changes to the database persistent between containers. If you omit that, the database will be isolated in the container and will disappear as soon as you delete the container.

    See Managing data in containers (Docker documentation) for details.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.