Dokku/Docker, how to access file in file system of running container?

Previously, to access a file in a running dokku instance I would run:
docker ps to get the container ID followed by
ls /var/lib/docker/aufs/diff/<container-id>/app/...
note: I’m just using ‘ls’ as an example command. I ultimately want to reference a particular file.

This must have changed, as the container ID is no longer accessible via this path. There are loads of dirs in that folder, but none that match any of the running containers.

  • Refer to another service/task running in same ECS cluster
  • Virtual machine disk space in Docker for Windows beta
  • Why doesn't “pip install” work with Flask and gevent inside a debian docker container?
  • How can I use docker for drupal?
  • Cannot connect Robomongo using MongoDB docker image
  • Docker 1.12: Multiple replicas, single database
  • It seems like mounting a volume for the entire container would be overkill in this scenario. I know I can access the file system using dokku run project-name ls, and also docker exec <container-id> ls, but neither of those will satisfy my use case.

    To explain a bit more fully, in my dokku project, I have some .sql files that I’m using to bootstrap my postgres DB. These files get pushed up via git push with the rest of the project.

    I’m hoping to use the postgres dokku plugin to run the following:

    dokku postgres:connect db-name < file-name.sql

    This is what I had previously been doing using:

    dokku postgres:connect db-name < /var/lib/docker/aufs/diff/<container-id>/app/file-name.sql but that no longer works.

    Any thoughts on this? Am I going about this all wrong?

    Thanks very much for any thoughts.

  • using system mongodb for multiple docker containers?
  • Is it possible to read messages passed over stdout from within a Docker container? (without `docker logs`)
  • The right way to move a data-only docker container from one machine to another
  • How to use RUN clone git in dockerfile
  • Identity Server 4 running within docker container Exception: Unable to load DLL 'System.Security.Cryptography.Native.OpenSsl'
  • Not able to access docker daemon api from docker container
  • 2 Solutions collect form web for “Dokku/Docker, how to access file in file system of running container?”

    Never rely on the /var/lib/docker file system paths as most of the data stored there is dependent on the storage driver currently in use so it is subject to change.

    cat the file from an existing container

    docker exec <container> cat file.sql | dokku postgres:connect db-name

    cat the file from an image

    docker run --rm <image> cat file.sql | dokku postgres:connect db-name

    Copy file from an existing container

    docker cp <container>:file.sql file.sql
    dokku postgres:connect db-name < file.sql

    Here example :

    dokku apps

    =====> My Apps


    dokku enter DummyApp

    Enter bash to the DummyApp container.

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