0

I'm relatively new to Docker.

I'm currently trying to run docker container on MacOS. The container is based on itzg/minecraft-server image. Running the container normal way works fine, however, what I want to do is sync all Minecraft server data with a specific directory.

For example, I want to make sure that when I create a docker container, all the data is created or synced with /Users/myname/MCServer (for example).

I learned here that I can do that by just appending -v as an argument, and then adding the directory that the server data should be located on.

I tried the following first:

docker run -v /Users/myname/Documents/MC Servers/Docker/Test:/data -d -it -p 32930:32930 -e TYPE=PAPER -e ONLINE_MODE=false -e SERVER_PORT=32930 -e EULA=TRUE -e VERSION=1.8.8 --name OpenSourcee itzg/minecraft-server

Well, that did not work so well throwing:

docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.

After some research, I figured out I could use ` sign to achieve the wanted effect. Also, I learned that MC Servers directory must not contain a space in the name, so I renamed it to MC_Servers. I also added sudo (but tried without as well). Here's the new command:

sudo docker run -v `/Users/myname/Documents/MC_Servers/Docker/Test` -d -it -p 32930:32930 -e TYPE=PAPER -e ONLINE_MODE=false -e SERVER_PORT=32930 -e EULA=TRUE -e VERSION=1.8.8 --name OpenSourcee itzg/minecraft-server

Unfortunately, that did not work as well, this time throwing:
zsh: permission denied: /Users/myname/Documents/MC_Servers/Docker/Test

After the error, server starts, but there are no files in /Users/myname/Documents/MC_Servers/Docker/Test...

I'd really appreciate if someone can tell me if -v tag is a way to make docker use the given directory to create my Minecraft server in and put all it's data into and if it is, than how to solve the permission error I'm experiencing.

Thanks!

2
  • Backticks are not quotes! They execute the enclosed command. Be careful, you could inadvertently run something.
    – Daniel B
    Commented Jun 13, 2022 at 17:28
  • Oh, didn't know that. Thank you for letting me know :)
    – OpenSource
    Commented Jun 13, 2022 at 20:00

1 Answer 1

1

Quote your volume definition. There's a space in there that would normally separate arguments, so docker is trying to find the image Servers/Docker/Test:/data which is not a valid image name.

docker run \
  -v "/Users/myname/Documents/MC Servers/Docker/Test:/data" \
  -d -it -p 32930:32930 \
  -e TYPE=PAPER \
  -e ONLINE_MODE=false \
  -e SERVER_PORT=32930 \
  -e EULA=TRUE \
  -e VERSION=1.8.8 \
  --name OpenSourcee itzg/minecraft-server
2
  • Thank you very much for your answer. It works, however, it seems like still, none of the Minecraft server files are in the given folder... Any suggestions on that maybe?
    – OpenSource
    Commented Jun 13, 2022 at 19:59
  • 1
    Actually, it was my bad. I forgot to add _ to MC_Servers. Thanks once again for your answer.
    – OpenSource
    Commented Jun 13, 2022 at 20:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .