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.

  • How to get container id of a docker service
  • Docker Container(Dockerfile from other image) immediately exit - It is all about Dockerfile not command
  • Is it possible to expose http ports with docker-compose?
  • Is it possible to access Hbase installed inside docker container to be accessed using java client on mac OSX?
  • I run a docker container,but after few minutes , it was killed by himself
  • can I mount subdir of volume in docker run command
  • 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.

  • nginx windows 10 upstream timeout
  • Restart Postgres in a docker
  • Cron isn't running when I start my docker container
  • ping returns unknown host
  • Clone private git repo with dockerfile
  • docker run mongo image on a different port
  • 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.