Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 2325
Alex Hales
  • 0
Alex HalesTeacher
Asked: May 31, 20222022-05-31T21:53:23+00:00 2022-05-31T21:53:23+00:00

Docker-compose volume not storing files

  • 0

[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]

  • 0 0 Answers
  • 8 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 2 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 4 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 3 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.