Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When starting S3Mock in Docker, root folder is not accessible from outside of the container #1728

Closed
ocostello opened this issue Mar 19, 2024 · 4 comments · Fixed by #1781
Closed
Assignees
Labels
documentation Questions and answers RE: missing documentation

Comments

@ocostello
Copy link

I'm attempting to set adobe/S3Mock up on my local machine, so that retainFilesOnExit is enabled and where I've pointed the root folder somewhere that I can view.

My docker-compose.yml looks like so:

services:
  s3mock:
    image: adobe/s3mock:3.5.2
    environment:
      - debug=true
      - retainFilesOnExit=true
      - root=s3container
    ports:
      - 9090:9090
      - 9191:9191

and when I start the server, the logs say that the root folder has been created:

Successfully created "/s3container" as root folder. Will retain files on exit: true

but I can't find it myself. I'm expecting it to appear in the directory I started the server in, and if not there then just at root /s3container but it isn't at either location.

➜  localS3 git:(main) ✗ ls
docker-compose.yml
➜  localS3 git:(main) ✗ docker compose up -d
[+] Running 1/1
 ✔ Container locals3-s3mock-1  Started                                                                                                                 0.0s
➜  localS3 git:(main) ✗ ls
docker-compose.yml
➜  localS3 git:(main) ✗ ls /s3container
ls: /s3container: No such file or directory

Am I seriously misunderstanding this root config, and if so could it be better explained in the docs.

@afranken
Copy link
Member

@ocostello

Am I seriously misunderstanding this root config

yes and no.

The property works for the application, but not the Docker container. Since the S3Mock application is running inside Docker, the folder you specify in root will be created inside the Docker container, not on your system.

If you want so see the data in your local file system, you'll have to create a directory and mount it so it's accessible from inside the Docker container, for example:

mkdir tobemounted

services:
  s3mock:
    image: adobe/s3mock:3.5.2
    environment:
      - debug=true
      - retainFilesOnExit=true
      - root=s3container
    ports:
      - 9090:9090
      - 9191:9191
    volumes:
      - ./tobemounted:/s3container

Then, Docker will be able to access your file system.

@afranken
Copy link
Member

Example:

 ~/tmp/s3mock-mount-test                                                                                                                                                                                                                                                                                                                                                                                                     at 19:26:40
❯ ls
docker-compose.yml tobemounted

❯ cat docker-compose.yml
services:
  s3mock:
    image: adobe/s3mock:3.5.2
    environment:
      - debug=true
      - retainFilesOnExit=true
      - root=s3container
    ports:
      - 9090:9090
      - 9191:9191
    volumes:
      - ./tobemounted:/s3container

❯ docker-compose up
[...]

❯ curl --request PUT "http://localhost:9090/my-test-bucket/"

^CGracefully stopping... (press Ctrl+C again to force)
[+] Stopping 1/1
 ✔ Container s3mock-mount-test-s3mock-1  Stopped                                                                                                                                                                                                                                                                                                                                                                                     0.1s
canceled

❯ ls tobemounted
my-test-bucket

@afranken afranken self-assigned this Mar 19, 2024
@afranken afranken added the documentation Questions and answers RE: missing documentation label Mar 19, 2024
@afranken afranken changed the title Root folder is not being created relative to the instantiation of the server When starting S3Mock in Docker, root folder is not accessible from outside of the container Mar 19, 2024
@ocostello
Copy link
Author

Thanks for the swift reply, that works perfectly now.

afranken added a commit that referenced this issue Apr 11, 2024

Verified

This commit was signed with the committer’s verified signature.
magbak Magnus Bakken
Fixes #1728
@afranken
Copy link
Member

@ocostello I added this description to the README.md, as it's hopefully helpful for other users as well:
https://github.com/adobe/S3Mock?tab=readme-ov-file#start-using-docker-compose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Questions and answers RE: missing documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants