expose files from docker container to host

Mr T.

I have a docker container that holds a django app. The static files are produced and copied to a static folder.
container folder hierarchy:

- var
    - django
        - app
        - static

before i build the docker image, i run ./manage.py collectstatic so the static files are in the /var/django/static folder. To expose the app and serve the static files, i have on the host an nginx. The problem is that if i do a volume between the static folder and a designated folder on the host, when i run the docker container, the /var/django/static folder in the container gets deleted (well, not deleted but mounted). Is there any way to overcome this? as in set the volume but tell docker to take the current files as well?

C. Reed

Volumes are treated as mounts in Docker, which means the host directory will always be mounted over the container's directory. In other words, what you're trying to do isn't currently possible with Docker volumes.

See this Github issue for a discussion on this subject: https://github.com/docker/docker/issues/4361

One possible work-around would be to have a docker volume to an empty directory in your container, and then in your Docker RUN command (or start-up script), copy the static contents into that empty directory that is mounted as a volume.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to expose port from host to container in Docker?

Docker: Copying files from Docker container to host

Copying files from Docker container to host

Copying files from host to Docker container

How to copy files from host to Docker container?

Docker - accessing files inside container from host

Docker: MacOSX Expose Container ports to host machine

How to expose Linux socket file from Docker container (MySQL, MariaDB, etc.) to host

How to expose host network to docker container in docker-compose?

How to copy files from one docker container to another on a different host?

How to find volume files from host while inside docker container?

Writing csv files to local host from a docker container

How to Copy Files From Docker Ubuntu Container to Windows Host

How to sync back files from a Docker container to its host?

Copy files from host to docker container then commit and push

How to copy multiple files from container to host using docker cp

Docker: prevent container from modifying host's files when binding

Docker COPY error when copying files from host to container

Is there a way to expose a docker container port bound to 127.0.0.1 to host?

Does docker EXPOSE refer to the container port or the host port?

Connecting from a docker container to the host?

Restarting host from docker container

Host monitoring from a docker container

Docker - connect from HOST to container

Docker container inaccessible from host

How to copy files from docker container to host using docker-compose in docker-machine

Expose a docker composed container with network_mode: "host" and keep container to container networking

How to expose a Docker container

sync files between docker container and host machine