docker-compose + how to set ramdisk insted of volumes

Viewed 1579

In docker-compose we set the following volumes:

volumes:
  - /var/kafka-data:/var/lib/kafka/data

So /var/kafka-data will mounted from /var/lib/kafka/data

Now we want to use ramdisk instead of mount between /var/lib/kafka/data to /var/kafka-data

The ramdisk command is like this

mount -t tmpfs -o size=100G ramdisk1 /var/kafka

the question is how to set the ramdisk cli in the docker-compose.yml instead of /var/kafka-data:/var/lib/kafka/data

1 Answers

The ramdisk command needs to be executed on the host and not in the docker container. Therefore, I would say add the tmpfs mount to the host /etc/fstab. same as shown below (example with tmpfs and ramdisk1)

tmpfs /var/kafka tmpfs uid=1001,gid=1001,size=10240m 0 0
ramdisk1  /data tmpfs nodev,nosuid,noexec,nodiratime,size=100G  0  0

execute mount -a or restart the node to mount the folder.

Update your docker-compose

volumes:
  - /var/kafka:/var/lib/kafka/data
Related