[ad_1]
I’m having trouble demonstrating that data I generate on a shared volume is persistent, and I can’t figure out why. I have a very simple docker-compose file:
version: "3.9"
# Define network
networks:
sorcernet:
name: sorcer_net
# Define services
services:
preclean:
container_name: cleaner
build:
context: .
dockerfile: DEESfile
image: dees
networks:
- sorcernet
volumes:
- pgdata:/usr/share/appdata
#command: python run dees.py
process:
container_name: processor
build:
context: .
dockerfile: OASISfile
image: oasis
networks:
- sorcernet
volumes:
- pgdata:/usr/share/appdata
volumes:
pgdata:
name: pgdata
Running the docker-compose file to keep the containers running in the background:
vscode ➜ /com.docker.devenvironments.code $ docker compose up -d
[+] Running 4/4
⠿ Network sorcer_net Created
⠿ Volume "pgdata" Created
⠿ Container processor Started
⠿ Container cleaner Started
Both images are running:
vscode ➜ /com.docker.devenvironments.code $ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
oasis latest e2399b9954c8 9 seconds ago 1.09GB
dees latest af09040befd5 31 seconds ago 1.08GB
and the volume shows up as expected:
vscode ➜ /com.docker.devenvironments.code $ docker volume ls
DRIVER VOLUME NAME
local pgdata```
Running the docker container, I navigate to the volume folder. There’s nothing in the folder — this is expected.
vscode ➜ /com.docker.devenvironments.code $ docker run -it oasis
[[email protected] opt]# cd /usr/share/appdata/
[[email protected] appdata]# ls
[[email protected] appdata]#
Since there’s nothing in the folder, I create a file in called “dog.txt” and recheck the folder contents. The file is there. I exit the container.
[[email protected] appdata]# touch dog.txt
[[email protected] appdata]# ls
dog.txt
[[email protected] appdata]# exit
exit
To check the persistence of the data, I re-run the container, but nothing is written to the volume.
vscode ➜ /com.docker.devenvironments.code $ docker run -it oasis
[[email protected] opt]# cd /usr/share/appdata/
[[email protected] appdata]# ls
[[email protected] appdata]#
What gives? I’ve tried defining the volume as persistent, and I know each of the images have a folder location at /usr/share/appdata
.
[ad_2]