Is it possible to mount folder from container to host machine?

As an example, I have a simple Node.js / Typescript application defined as follows:

Dockerfile

  • Elastic Beanstalk high CPU load after a week of running
  • how can I set the working directory in old version of docker in the run command?
  • Docker daemon wont start , do i need something configuration before?
  • How to develop Rails app running inside Docker
  • ERROR: for couchbase-db driver failed programming external connectivity
  • TFS workspace with Jenkins Docker container
  • FROM node:6.2
    
    RUN npm install --global typings@1.3.1
    
    COPY package.json /app/package.json
    
    WORKDIR /app
    
    RUN npm install
    
    COPY typings.json /app/typings.json
    
    RUN typings install
    

    Node packages and typings are preinstalled to image. node_modules and typings folders are by default present only in running container.

    docker-compose.yml

    node-app:
        ...
        volumes:
            - .:/app
            - /app/node_modules
            - /app/typings
    

    I mount current folder from host to container, which creates volumes from existing folders from /app. Those are mounted back to container so the application can work with them. The problem is that I’d like to see typings folder on host system as a read-only folder (because some IDEs can show you type hints that can be found in this folder). From what I’ve tested, those folders (node_modules and typings) are created on host machine after I run the container, but they are always empty. Is it possible to somehow see their contents (read-only preferably) from container volumes only if the container is running?

  • “debconf: delaying package configuration, since apt-utils is not installed” :> google notebooks bash error
  • Could not save file in the docker image after “docker commit”
  • Docker error on Windows 2016 “Client.Timeout exceeded while awaiting headers”
  • Cannot connect externally to a docker container running CherryPy server
  • How to run meanstack in docker
  • PCI passthrough strategy in Docker or oVirt
  • One Solution collect form web for “Is it possible to mount folder from container to host machine?”

    You can’t make a host directory read-only from Compose. Compose orchestrates containers, not the host system.

    If you want to share directories with the host, create them on the host first and mount them as bind volumes (like you’ve done with .:/app)

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