yarek
yarek

Reputation: 12044

How to serve a docker content folder to my apache server?

I have my server running apache on port 80 and a docker images running on that server as well. I want to HTTP publish/map the content of /var/www/ from my docker to /var/www/docker on my real server

So when I run http://myserver/content it fetches the content on my docker /var/www

Is there a way to do that ?

Upvotes: 1

Views: 3342

Answers (2)

whites11
whites11

Reputation: 13260

When you run your docker image, mount a volume by adding this flag:

docker run ... -v /var/www/docker:/var/www ... <Your image name>

This way, the contents of the /var/www/docker folder in your host will be available in the /var/www folder inside your container.

Upvotes: 0

fzgregor
fzgregor

Reputation: 1897

That is what volumes are for. With a volume a path inside of the container is mounted/bound on a path outside of the container. This allows both domains to access the files in that file system subtree.

To do what you describe (have /var/www/docker/ on the host be the same as /var/www/ in the container) you would call docker like this:

docker run [...] -v /var/www/docker:/var/www [image-name]

Upvotes: 1

Related Questions