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.

  • Kubernetes vs Kubernetes on Mesos? [closed]
  • Ansible docker module missing CP command?
  • How to apply kernel tuning on docker container
  • (mac) dockers , commit changes in mongo doesn't work
  • Updating Task Definitions in ECS
  • linux clone() returning -1 as child_pid
  • 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.

  • Docker: can't RUN psql commands from Dockerfile
  • docker-compose setup doesn't allow container to connect to redis
  • Oauth authentication in Apache SuperSet
  • example to deploy docker image on kubernetes from java
  • How to dynamically set environment variables of linked containers?
  • Does using a Docker significantly improve the IO and processing speed?
  • 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

    DummyApp

    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.