Single file mount to docker container is not working

Viewed 837

I'm trying to map one single file which is exist in the container with an edited copy which exist in my host by using docker-compose file. But it's not working. could someone please help me to fix this?

I'm not getting any error. But when i do a change on the file in host, its not reflecting inside the container.

docker-compose entry

enter image description here

Both files in host and docker container have 777 permission.

2 Answers

I've figured out what the issue is. when mounting a single file and editing it, use the nano editor to edit the files or turn off swapfiles before using vim. when using vim, its creating a swapfile and replacing the existing one. therefore the file bind link is breaking. thats why the changes are not reflecting both sides.

You need to use the mount type as bind instead of volume.

st2stream: 
  image: ${ST2_IMAGE_REPO: -stackstorm/}st2stream: ${ST2_VERSION:-3.3.0} 
  restart: always 
  depends_on : 
    - st2api 
  networks: 
    - private 
  volumes: 
    - ./files/st2. docker.conf:/etc/st2/st2.docker.conf:ro 
    - ./files/st2.user.conf:/etc/st2/st2.user.conf:ro 
    - type: bind
      source: /opt/automation/projects/stackstorm/st2-docker/configs/st2stream/logging.docker.conf
      target: /etc/st2/logging.docker.conf
    - /opt/automation/projects/stackstorm/st2-logs:/var/log/st2:rw
Related