I’m new to Docker and I’m following the basic instructions. I can get something running following the instructions step by step, but the instant I try to do something myself everything stops working. In particular I’m utterly mystified about the relationship between the file system in a container and the file system on my local disk.
I thought that the idea of Docker was that it should be isolated, but it quite clearly isn’t. A write to files inside a running container shows up as a write to files on my local disk. This means I can’t have multiple containers for the same image as they’ll all be fighting over access to my local disk.
I’m running a basic Rails app https://docs.docker.com/compose/rails/ with the web and db in separate images and separate containers. My docker compose is
version: '3' services: db: image: postgres volumes: - ./tmp/db:/var/lib/postgresql/data web: build: . command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: - .:/myapp ports: - "3000:3000" depends_on: - db
When I run the app it works! Great but updates to the log file in the docker_web_1 container show up as updates in my local log/development.log
I’m guessing this is because the lines in the docker-compose.yml
volumes: - .:/myapp
Are sharing the directory in the container with my local directory. Why?
What I want is a set of containers, each with their own IP address and isolated file systems and databases, that can communicate with each other. What’s the best way to do this?